[英]Product database schema redesign
我设计商店来出售定制的机加工零件。 目前,我的产品实际上是产品包(选件)。 模式如下所示:
types
id, name
products
id, type_id, name
optiontypes
id, name
options
id, type_id, name
product_option
id, product_id, option_id
carts
id, session, product_id
cart_option
id, cart_id, option_id
orders
id, name
order_option
id, order_id, option_id
我的问题是我有回头客购买了包裹,现在想购买单个物品进行更换。 我当时在考虑将选项类型合并为类型,将选项合并为产品,但是我如何才能算出打包产品还是单个产品呢?
在阅读了BOM表-从pst的评论中了解模块化物料清单后,我打算这样做:
------------------------------------
ORDER: 1001
package1
module1
component1
component2
module2
component3
component4
component5
------------------------------------
ORDER: 1002
component1
component5
------------------------------------
ORDER: 1003
package2
module1
component1
module2
component3
------------------------------------
我将如何寻找兼具两者的最佳解决方案?
好的,所以一个包装包含一个或多个零件 。 客户可以订购一个或多个包装和/或一个或多个零件 。 由于我不知道选项是什么,所以我或多或少地将其与* part_type *合并,因此也许您具有铝制零件类型以及预钻孔的铝制零件类型。
您的订单会跟踪订购了哪些包装以及订购了哪些单独的零件 。 如果我正确地理解了您的意见,那么作为包装的组成部分出售的部件或单独出售的部件之间没有物理差异-您只需要能够跟踪其购买方式即可。 像这样进行设置可以让您跟踪该情况。
packages
id unsigned int(P)
description text // This package contains all the parts you need to build SuperMegaWidget!
packages_parts
id unsigned int(P)
package_id unsigned int(F packages.id)
part_id unsigned int(F parts.id)
part_types
id unsigned int(P)
name varchar(50) // Aluminum, Brass, whatever, etc.
parts
id unsigned int(P)
part_type_id unsigned int(F part_types.id)
name varchar(50) // Widget A, Widget B, etc.
orders
id unsigned int(P)
... lots of other information in here
orders_packages
id unsigned int(P)
order_id unsigned int(F orders.id)
package_id unsigned int(F packages.id)
orders_parts
id unsigned int(P)
order_id unsigned int(F order.id)
part_id unsigned int(F parts.id)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.