我正在开发产品数据库,对于尺寸,我创建了一个单独的表格PRODUCT_SIZE(id,sizetext)
例如(1,"小"),(2,"大"),(3,"超大"),...
我提供了这些尺寸列表作为复选框,当添加产品时,可以根据当前产品选择所有可能的尺寸。
例如,对于 T 恤、小号和大号,选择。
这 2 大小可用于每个新购买的股票条目。现在我知道,可以有不同的尺寸单位,有些项目可以以英寸为单位,有些以公斤为单位,有些以米为单位。
我想到了一个改变的解决方案:更改表
PRODUCT_SIZE(id,sizetext, UNitType);
KG'),(3,'2.5'。英寸),...
建议更好吗?
您似乎将"服装尺码"、"重量"和"长度"强加到一个"尺码"属性中。
试试这些表:
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中添加"显示顺序"(以便"小"可以在"大"之前显示)。
也对你的其他属性执行此操作。
我已经为一个生产站点做了这个,我认为它运作良好。
祝你好运。
与其为此创建一个单独的表,不如将所有下拉选项放在应用程序范围的变量中呢? 然后,您可以将该数据作为字符串直接添加到产品中的字段中,并以编程方式处理不同的选项/单位。
我创建了一个数据库,存储衣服的尺寸有几种类型。一篇文章的大小像 xs s m l 另一个是26 27 28 29 30 等等。我决定这样做:
# on one side in the script i define size types and names;
$sizeTypes[1] = [XS, S, M, L];
$sizeTypes[2] = [29, 30, 31, 32];
#The and so on
#and on the other side in the database, there are just two columns
size_type_id(int) | size_qty |
# so if I have one article with 3 pieces of size S 2 pieces of size M and 5 pieces of size L the database will store:
size_type_id| size_qty |
1 |0:0;1:3;2:2;3:5|
然后在脚本中我只是翻译它,以便类型 1 的 0 是 XS,类型 1 的 1 是 S 2 的类型 2 是 31,依此类推