The joint primary key also plays an important role in taking care of the uniqueness of the data in the case of a large number of visits. The user can only evaluate the purchased product once. The self-incrementing ID of the evaluation is useless. The joint primary key composed of the user's ID and the product ID is much more meaningful.
CREATE TABLE `order_comment` ( `user_id` int(11) NOT NULL DEFAULT '0', `order_id` int(11) NOT NULL DEFAULT '0', `name` varchar(30) NOT NULL, `address` varchar(60) NOT NULL, PRIMARY KEY (`user_id`,`order_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
order item
CREATE TABLE `orders_items` ( `order_id` int(11) DEFAULT '0' COMMENT 'Order ID', `product_id` int(11) DEFAULT '0' COMMENT '商品ID', `stock_name` varchar(80) DEFAULT '' COMMENT 'Commodity name', `stock_pre_price` decimal(10,2) DEFAULT '0.00' COMMENT 'Unit price of commodity', `stock_num` int(11) DEFAULT '0' COMMENT 'Number of items', PRIMARY KEY (`order_id`, `product_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;