问题描述
我正在开发产品数据库,对于大小,我创建了一个单独的表PRODUCT_SIZE(id,sizetext)
I am developing product database, for sizes i created a separate table PRODUCT_SIZE(id,sizetext)
(1,'Small'),(2,'Large'),(3,'Extra Large'),...
e.g. (1,'Small') ,(2,'Large'), (3,'Extra Large'),...
,当添加产品时,可以针对当前产品选择所有可能的尺寸。
I provided These sizes list as checkbox, when a product is added, all possible sizes can be selected against current product.
例如对于选择的T恤,SMALL和LARGE尺寸。
e.g. for T-Shirt, SMALL, and LARGE sizes selected.
这两个尺码可用于每个新股票购买条目。
现在我知道,可以有不同的尺寸单位,一些项目可以英寸,一些以kg为单位,一些以米为单位。
these 2 Sized are available against each new stock purchased entry.Now i came to know, that there can be different size units, some items can be in inches, some in kg, and some in meters.
改变了解决方案:
to alter table
I have a altered solution in mind:to alter table
PRODUCT_SIZE(id,sizetext,UNitType);
现在可以是:(1,'5','KG'),(2,'10','KG'), '。'Inches'),...
Now it can be: (1,'5','KG') ,(2,'10','KG'), (3,'2.5'.'Inches'),...
是否有更好的建议?
推荐答案
似乎你正在将'服装尺寸','重量'和'长度'变成一个'尺寸'属性。
It seems like you're forcing 'clothing size', 'weight' and 'length' into one 'size' attribute.
这些表格:
product (product_id, name)
"Nike t-shirt"
attribute_group (attribute_group_id, name)
"Shirt size", "Weight", "Length", etc.
attribute_value (attribute_value_id, attribute_group_id, name)
"Shirt size" would have rows for "Small", "Large", etc.
product_attribute (product_id, attribute_value)
"Nike t-shirt" is "Large"
向attribute_value中添加显示顺序(因此Small可以在Large之前显示)。
Add a "display order" to attribute_value, too (so "Small" can be displayed before "Large").
为你的其他属性也这样做。
Do this for your other attributes, too.
我为一个生产站点做了这个,我认为它工作得很好。
I've done this for a production site, and I think it worked well.
祝你好运。
这篇关于mysql最好的方式来管理产品大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!