[英]Product attributes per category
I have a category table with category id, name and parent. 我有一个带有类别ID,名称和父类别的类别表。 I have a products table with a link to the category table named
cat_id
. 我有一个带链接到名为
cat_id
的类别表的产品表。
Now I have diffrent kind of products and not every product has the same kind of attributes like colour or pieces. 现在,我有不同种类的产品,并不是每个产品都具有相同的属性,例如颜色或碎片。 So my problem is: How to setup that I can have different attributes per category?
所以我的问题是:如何设置每个类别可以具有不同的属性?
I am stuck at how I can best link this. 我一直在坚持如何最好地链接到此。 Now I have a column in the products table with all the attributes, but also the ones that are not used per category.
现在,我在products表中有一列,其中包含所有属性,但还有每个类别未使用的属性。
Make an attribute category table: 制作一个属性类别表:
attcat_id
attcat_name
attcat_id
attcat_name
Make an attribute table: 制作一个属性表:
att_id
attcat_id
(foreign key) att_name
att_id
attcat_id
(外键) att_name
This way these two will be linked 这样这两个将被链接
Now in category table associate each category with attribute category 现在在类别表中将每个类别与属性类别相关联
cat_id
cat_name
attcat_id
(foreign key) cat_id
cat_name
attcat_id
(外键)
So idea is to group attributes as per attribute category and link attribute category to Product Category. 因此,想法是按照属性类别对属性进行分组,然后将属性类别链接到“产品类别”。 For example, an attribute category
mobile
will have attributes as price
screensize
camera
flashlight
. 例如,属性类别
mobile
将具有属性,如price
screensize
camera
flashlight
。
Now link mobile
ie attribute category to your product category Mobiles
. 现在将
mobile
即属性类别)链接到您的产品类别“ Mobiles
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.