There are two types of information that we want to store when an order is placed:
??? Details about the order as a whole: What date was the order created? Have the products
have been shipped and, if so, when were they shipped? And what??™s the order??™s status now?
We??™ll store this data in a table named orders, where each record represents an order.
??? Product details for the order: What products were ordered in which order? We??™ll store
this data in a table named order_detail, where each record represents an ordered
product. Many records of this table will be associated with one record in the orders
table, forming a one-to-many relationship between the tables (you might want to
revisit Chapter 5, where the table relationships are explained).
?– Tip So far, we have been consistent about naming our tables in singular form (shopping_cart, department,
and so on). However, here, we make an exception for the orders table, because ORDER is an SQL keyword.
For the purposes of this book, we prefer to break the naming convention to avoid any confusion while writing
the SQL code, and generally speaking, it isn??™t good practice to use SQL keywords as object names.
The orders table stores information regarding the order as a whole, while order_detail
contains the products that belong to each order. We??™ll create the tables in the following exercise.
Pages:
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549