Jump to content

DB newb ?


compphenom

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.