I have a shopping cart in which I have to keep track of stock, and this includes stock with attributes. For example:
shirt
-- blue, small = 50
-- blue, medium = 22
-- blue, large = 53
-- red, small = 15
etc...
These fields are currently separated by commas in the database and the IDs would be as follows:
1,3
1,4
1,5
2,3
where each number represents a specific attribute (1=blue,3=small). The problem is that this then becomes very hard to work with as the data is not atomic in the database, but I cannot think how to structure the table, as there could be infinitely many combinations of items such as:
blue, small, long-sleeved
Can anybody suggest a better way of storing this information in the database? I thought of using lookup tables but this would not work due to the varying number of attributes.