compphenom Posted March 24, 2003 Share Posted March 24, 2003 I have a question with regards to a database\'s structure. I am not all that proficient with databases, but have managed to get into a situation where I am building a website in PHP and now need to connect to a database. I have a table with productId, productName, productTitle, productDescription, productPrice, etc. The problem I am running into is that each product comes in any one of 16 colors, however not all. Product A may come in 12 colors while product B might come in all 16 colors and product C comes in only 6 colors. I am trying to dynamically fill a list box with each product\'s available colors, but I do not know the database structure to accomplish this. Any comments welcome, I hope I have explained this adequately. - Kevin Quote Link to comment Share on other sites More sharing options...
9AF Posted March 25, 2003 Share Posted March 25, 2003 Hi Hi Kevin You will need to create another table called Product Colour for example with the following structure: id - (autonumber) - primary key colour - (varchar) productid - foreign key You will need to have a one-to-many relationship between the tables \'Product\' (one side) and \'Product Colour\' (many side) with productid as the foreign key in table \'Product Colour\'. In this new table you can then associate a colour to each specific product. This should resolve your prob. Hope this is ok. RB Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.