电子商务数据库 ERD 帮助
这实在是太伤脑筋了,我真的需要帮助! 这就是我想要实现的目标。
我有一个表名称产品。 产品可能有也可能没有最多两个可选字段。示例颜色和尺寸。
如果产品没有可选字段,则只有一行价格和数量,否则每一行可选字段都有一个价格和数量。
我知道这听起来令人困惑,请原谅我。我也很困惑。 ): 但我可以在下面给你们举几个例子。
因此,价值一百万美元的问题是,我应该创建哪些表及其字段?
[ 没有可选字段的产品 ]
价格 |数量
1.00 美元 | 2
[ 具有一个可选字段的产品 ]
价格 |数量 |尺寸
1.00 美元 | 2 |大号
2.00 美元 | 1 |小
【产品有两个可选字段】
价格|数量 |尺寸|颜色
$1.00 | 2 |大|绿色
$2.00 | 1 |小| Blue
我提出了一个想法,让两个名为 Product 和Optional 的实体与Optional 实体建立多对多关系来存储字段名称(例如 Size),而连接实体名称 Product_Optional 将存储值(例如 Large)。
但是,我仍然遇到如何将一种产品的两个可选字段绑定到相同价格和数量的问题!抱歉让您感到困惑:(
This is frying my brain, I really need help!
Here is the thing i want to achieve.
I have a Table name Product.
The product may or may not have up to two Optional field. Example Color and Size.
If the product does not have the optional field, it will have only one row of Price and Quantity, else for each row of optional field, there will be one price and Quantity.
I know this sound Confusing, pardon me. I'm confused too. ):
But i can give you guys fews example below.
So the one million dollar question is, what are the tables and it's field i should create?
[ Product Without Optional Field ]
Price | Quantity
$1.00 | 2
[ Product With One Optional Field ]
Price | Quantity | Size
$1.00 | 2 | Large
$2.00 | 1 | Small
[ Product With Two Optional Field ]
Price | Quantity | Size | Color
$1.00 | 2 | Large | Green
$2.00 | 1 | Small | Blue
I come up with an idea of having Two entity named Product and Optional to have many to many relationship with the Optional Entity to store the field name, example Size and the junction-entity name Product_Optional will store the value, example Large.
However I'm still stuck with the issue of how to bind the Two Optional Field of one product to the same price and quantity! SORRY to be confusing :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:
由于您的选项未知,您可以执行以下操作
Products
ProductOptions
ProductInventory
那么您在 ProductInventory 中的记录将如下所示:
等等
更详细的示例,使用上面的表结构:
Products
ProductOptions
ProductInventory
等
Edit:
Since your options are unknown, you could do something like this
Products
ProductOptions
ProductInventory
Then your records in ProductInventory would look like:
etc etc
More detailed example, using the table structure above:
Products
ProductOptions
ProductInventory
etc
我遇到了同样的问题,我认为你也需要不止一张桌子。试试这个:
products
Product_options
Product_options_values
使用product_options_id 作为外键将您的product_options_values 链接到您的product_options。示例:product_option 'size' 的 Product_option_values 为 'small'、'medium'、'large'*
Product_options_to_products
此表将您的产品链接到您的选项。在这里,您可以为不同的产品分配不同的选项。
I have run into the same problem, and I think you need more than one table as well. try this:
products
Product_options
product_options_values
link your product_options_values to your product_options using product_options_id as foriegn key. example: product_option 'size' has the product_option_values of 'small', 'medium', 'large'*
product_options_to_products
this table links your products to your options. here you'd assign different options to different products.