Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2006
    Posts
    1

    Unanswered: 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!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •