Forum Moderators: coopster

Message Too Old, No Replies

product attributes problem?

         

PHPycho

5:59 am on Sep 17, 2007 (gmt 0)

10+ Year Member



Hello forums!
while trying to design a database for shopping cart i encountered few problems which i am mentioning here.
I had hierarchical level of categories for products for which i designed table as:
id宇itle如arent_id

Different products under different cateogries has different attributes ie for example products under
'Clothing' has different attributes than products under 'Music'. It means we cant have static form fields for attributes.I tried to
figure out this table for storing products attributes and values
id圭ategory_id地ttribute_name地ttribute_type
id地ttribute_id地ttribute_value

I think this is bit tedious in retrieving and displaying the attribute name and its corrsponding form field type, and also tedious in dynamically inserting, updating etc operations
is there any effective methods for such case?
I would really appreciate if there is alternative.
Thanks in advance for the comments and suggestions.

d40sithui

12:15 pm on Sep 17, 2007 (gmt 0)

10+ Year Member



phpycho,
sounds like a good start! I dunno if it would be tedious to update as you say. Here is a slighty version of the table schema. You will most like need at least 2 tables. Firs you have an item_table(item_id int primary key auto_increment, cat_id int, item_name text). Then you have the attribute_table(item_id int, att_id int primary key auto_increment, att_type varchar(50), att_name varchar(30), att_value text). you can easily create a form to add/remove/edit certain attributes by the att_id field in onjunction with the item_id. this also makes it easy to retrieve different attirbute for each item because each item will have different attributes and numbers associated.