Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql管理产品大小的最佳方法_Mysql_Database_Inventory_Stock - Fatal编程技术网

mysql管理产品大小的最佳方法

mysql管理产品大小的最佳方法,mysql,database,inventory,stock,Mysql,Database,Inventory,Stock,我正在开发产品数据库,我为尺寸创建了一个单独的表product_SIZE(id,sizetext) e、 (1,'Small'),(2,'Large'),(3,'Extra-Large') 我将这些尺寸列表作为复选框提供,当添加产品时,可以根据当前产品选择所有可能的尺寸 e、 g.对于T恤,选择小尺寸和大尺寸 这两种尺寸可用于每个购买的新股票条目。 现在我知道了,可以有不同的尺寸单位,有些物品可以是英寸,有些是千克,还有一些是米 我有一个改变的解决方案: 更改表格 产品大小(id、sizetex

我正在开发产品数据库,我为尺寸创建了一个单独的表product_SIZE(id,sizetext)

e、 (1,'Small'),(2,'Large'),(3,'Extra-Large')

我将这些尺寸列表作为复选框提供,当添加产品时,可以根据当前产品选择所有可能的尺寸

e、 g.对于T恤,选择小尺寸和大尺寸

这两种尺寸可用于每个购买的新股票条目。 现在我知道了,可以有不同的尺寸单位,有些物品可以是英寸,有些是千克,还有一些是米

我有一个改变的解决方案: 更改表格

产品大小(id、sizetext、UNitType)

现在它可以是:(1,'5','KG'),(2,'10','KG'),(3,'2.5','Inches')


还有更好的方法吗,建议?

与其为此制作单独的表格,不如将所有下拉选项都放在应用程序范围的变量中?然后,您可以将该数据作为字符串直接添加到product中的字段中,并以编程方式处理不同的选项/单位。

似乎您正在将“衣服尺寸”、“重量”和“长度”强制添加到一个“尺寸”属性中

尝试以下表格:

  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"
将“显示顺序”也添加到属性_值中(因此“小”可以在“大”之前显示)

对其他属性也要这样做

我已经为一个生产站点做了这项工作,我认为它工作得很好


祝你好运。

我建立了一个数据库,存储了几种尺码的衣服。一篇文章的尺码像xs s m l,另一篇文章的尺码像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是1型的XS 1是2型的s2是31,依此类推,大小可以从管理面板中添加/删除。对于未来的产品,管理员可以输入与产品相关的尺寸。啊,如果尺寸是动态的,那么您最好使用您的方法。