Java 非常简单的网店数据库设计
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9727143/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Very simple online shop database design
提问by ASD
I need to create a simple database for simple online shop. I crated the following one desing scheme, but I am not sure about correctness of it. Does it correct? What are mistakes?
我需要为简单的在线商店创建一个简单的数据库。我创建了以下一个设计方案,但我不确定它的正确性。它正确吗?什么是错误?
Like here:
像这儿:
http://netbeans.org/kb/docs/javaee/ecommerce/data-model.html
http://netbeans.org/kb/docs/javaee/ecommerce/data-model.html
but I want to add shopping cart
但我想添加购物车
采纳答案by Michael Fredrickson
I see one potential issue:
我看到一个潜在的问题:
If a user
has one shopping_cart
, and a shopping_cart
has one user
, should order
contain both user_id
and shopping_cart_id
?
如果 auser
有一个shopping_cart
,ashopping_cart
有一个user
,应该同时order
包含user_id
和shopping_cart_id
?
What ensures that these two IDs in this table reference a user
and shopping_cart
that are also associated with each other?
什么确保此表中的这两个 ID 引用 auser
并且shopping_cart
它们也彼此关联?
EDIT:
编辑:
I would just get rid of shopping_cart
, since it only contains totals that you would probably be better off calculating based on the current contents of the order.
我只想摆脱shopping_cart
,因为它只包含您可能最好根据订单的当前内容进行计算的总数。