If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > HELP: relationship database design

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-08-06, 01:00
Netasia Netasia is offline
Registered User
 
Join Date: Sep 2006
Posts: 1
HELP: relationship database design

Hi all, I'm new database design and I run into a problem while doing my project.

May I know what is a more effective way of designing a product listing database where each category can have mulitple products and a product can appears under multiple categories?

I figured if I limit the number of categories, I can easily solve the issue, however the project requires us to let user create unlimited categories.

Any help would be much appreciated.
Thanks!
Reply With Quote
  #2 (permalink)  
Old 09-08-06, 05:52
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
a table for categories, a table for products, then a third table, the relationship table, which associates products and categories

there can be multiple rows in the third table for a single product, and multiple rows for a single category

this third table will have only two columns, the product_id and the category_id, each of which is a foreign key to its respective table

together, the two columns form a composite primary key (so that you cannot put the same product into the same category moire than once)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On