为我的网站建立数据库
我需要帮助为我的在线定制西装商店设计数据库。到目前为止,我已经为产品、订单和我的用户/客户创建了表。我认为我需要添加一些表格来在客户进行选择和定制时管理我的购物车。此时,我对如何继续感到有点困惑。我的购物车是否需要保存我的订单表最终将保存的所有信息?从附图中可以看到,订单有订单项目,订单项目有订单项目选项。这样,我可以提取客户想要的每个订单项目,以及每个特定订单的所有自定义项。这是否需要首先在我的购物车中完成,这意味着我基本上必须复制数据库订单部分中的所有表,还是有更好的方法?另外,为了稳健地运行 www.indochino.com 这样的网站,我的数据库应用程序还缺少什么?
感谢所有帮助...
I need help designing the database for my online custom suit store. So far, i have created the tables for the products, orders, and my users/customers. I think I need to add some tables to manage my shopping cart for customers while they are making their selections and customizing them. At this point, i am a little confused on how to proceed. does my shopping cart need to pretty much hold all the information that my orders tables will hold ultimately? as you can see from the attached image, orders have order items, and order items have order item options. this way, i can pull up each order item that a customer wants, and all of the customizations that go with each particular order. Does this need to first done in my shopping cart, meaning that i would basically have to replicate all of the tables in the orders section of the database, or is there a better way? Also, what else is my database application lacking in order to robustly run a website like www.indochino.com?
All help is appreciated...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该将
order
表更改为shopping_cart
表,并从中删除所有送货地址信息。然后创建一个单独的
order
表,其中包含指向关联购物车的shopping_cart_id
。此订单
表应包含已发布订单的所有必要信息,例如送货地址、行项目总金额、税额、订单总金额、发布日期时间等。我不知道不要认为状态字段是正确的方法,因为购物车不是订单,并且很多订单字段不适用于购物车。这些字段不应采用空值,因为它们是已完成订单所必需的。当需要编写有关此数据的报告时,根据状态字段存储完全不同内容的表是一种负担。
You should change your
order
table to be ashopping_cart
table, and remove all of the shipping address information from it.Then create a separate
order
table that includes ashopping_cart_id
that points to the associated shopping cart. Thisorder
table should include all of the necessary information for a posted order, like shipping address, line-item total amount, tax amount, order total amount, posted-date-time, etc.I don't think a status field is the correct approach, because a shopping cart is not an order, and lots of order fields are not applicable to a shopping cart. These are fields that should not take a null value, because they are required for a completed order. Tables that store completely different things depending on a status field are a burden when it comes time to write reports on this data.
我认为您不需要单独的桌子来放置购物车。我只需使用现有的 order/order_item 表来保存购物车信息,然后在订单上添加一个状态字段,其中包含“不完整”、“完整”、“已发货”等值。任何不完整的订单都是呈现为购物车。恕我直言,状态机将是管理订单生命周期的良好选择。
I don't think you need a separate table for a shopping cart. I would just use the existing order/order_item tables to hold the shopping cart information, and then add a status field on order that held values such as "incomplete", "complete", "shipped", etc. Any orders that are incomplete are rendered as the shopping cart. A state machine would be good candidate for managing the lifecycle of the order, IMHO.
假设您的购物车是一个单独的表,它应该有 orderid 和 userid 作为外键。
Assuming your shopping cart is a separate table, it should have orderid and userid as foreign keys.
如果您在订单表上放置“in_cart bit”列,它会起作用吗?这样,您可以使用相同的表,但在订单尚未最终确定的情况下将 in_cart 设置为 1。
Would it work if you put an "in_cart bit" column on the order table? That way you can use the same tables but set in_cart to 1 where the order is not finalized yet.