客户与购物车中的订单之间的关系 [英] Relationship between Customer and Order in a Shopping Cart
问题描述
我对订单和客户之间的关系感到困惑。
如果没有错误,客户可以订购很多产品,
一个订单可以由1个客户
所以
创建表OrderProduct(
orderProductId int PRIMARY KEY,
productID int,
数量int
)
创建表订单(
OrderId int PRIMARY KEY,
orderProductId int,// foregin key
CustomerId int,
date
)
我是正确的,还是mu表结构错误?
对我来说似乎很好,但是在OrderProduct表中需要一个OrderId才能链接订单详细信息到订单 - 从订单中删除OrderProductId。
当然,其他一些列,如ProductId和CustomerId也应该是外键。
是订单是最终订单还是稍后开具发票?因为您通常可能希望按订单锁定单价(从订单时的产品文件或签名/批准的报价)。
I'm making an ERD, so that I can build my shopping cart.
I am confused about the relationship between Order and Customer.
If im not mistaken, a customer can order many products,
an order can be placed by 1 customer
So
Create Table OrderProduct(
orderProductId int PRIMARY KEY,
productID int,
Quantity int
)
Create Table Orders(
OrderId int PRIMARY KEY,
orderProductId int, //foregin key
CustomerId int,
date
)
Am I correct, or is mu table structure wrong?
That seems fine to me, but you need a OrderId in the OrderProduct table in order to link the order details to the order - drop the OrderProductId from Orders.
Some of the other columns like ProductId and CustomerId should also be foreign keys, of course.
Is an "Order" a finalized order or is there a later invoicing step? Because you typically may want to lock in the unit price at the order (from the product file at the time of the order, or perhaps from a signed/approved quote).
这篇关于客户与购物车中的订单之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!