Current location - Plastic Surgery and Aesthetics Network - Wedding planning company - How to determine the primary key of consumption order table
How to determine the primary key of consumption order table
There are several explanations on how to determine the primary key of the consumption order table: automatic numbering (order_id, self-increasing primary key) |-order number (order_no, the unique value inquired by customers) |-store number (shop_id, automatic numbering of the store table) |-order.

The commodity list stores commodities, including commodity names, descriptions, picture links, etc. , and store the properties of the goods.

The category table has a category id and a category name. There are many commodities under a category, and each commodity belongs to a certain category. Therefore, the category list and the commodity list have a one-to-many relationship.

The order details table stores the specific contents of the order, such as what goods were purchased and how many orders were purchased for each product. The main table includes buyer information, total order amount and whether it has been paid. There is a one-to-many relationship with the order list. If an order buys two kinds of goods, there will be two records in the schedule. A foreign key means a reference relationship. As long as a field in a table is the primary key in other tables, it can be defined as a foreign key whether it is the primary key of this table or not. In fact, the definition of foreign keys needs to be logical.