数据库由四个表,客户,订单,order_item和产品组成。当前客户表包含2个客户,产品表包含4个产品。假设cutomer_id:1,购物车中有product_id:1和product_id:2。
如何在表order和order_item中插入信息,其中order获取客户的全名,customer_id和order_items获取order_id的密钥
客户:
+-------------+------------+-----------+----------+
| customer_id | first_name | last_name | city |
+-------------+------------+-----------+----------+
| (PK)1 | Joe | Katz | Brooklyn |
| (PK)2 | Mike | Smith | Brooklyn |
+-------------+------------+-----------+----------+
订单:
| order_id | customer_id | order_status | customer_name |
+----------+-------------+--------------+---------------+
| (PK) | (FK) | | |
+----------+-------------+--------------+---------------+
order_item:
+---------+----------+------------+----------+------------+
| item_id | order_id | product_id | quantity | list_price |
+---------+----------+------------+----------+------------+
| (PK) | (FK) | (FK) | | |
+---------+----------+------------+----------+------------+
产品:
+------------+--------------+------------+
| product_id | product_name | list_price |
+------------+--------------+------------+
| (PK)1 | jeans | 45 |
| (PK)2 | shoes | 100 |
| (PK)3 | socks | 7 |
| (PK)4 | coat | 160 |
+------------+--------------+------------+