#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    17
    Rep Power
    0

    Need advice about creating db tables


    Hi guys,

    I'm creating a new DB for a project. I have a table for "Domains", now each Domain can have several Categories (Sports, Gambling, etc).
    I was think of creating a table for Categories but I am not sure how to link them to the Domains. I mean if a Domain have multiple categories I can't just add a column in the Domains table and because a Category can be applied to multiple Domain there's no reason to put a Domain column in the Category table. So what, do I create a CategoryPerDomain table ? It seems a bit redundant, no ?

    Any advice ??
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,730
    Rep Power
    1959
    Sounds correct. You will need a third table for this.

    If you want more information, you can read about Many to Many datamodel as well as Associative entity.

    Another must-read topic is Database normalization. (In case you haven't read about it yet)
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    17
    Rep Power
    0
    Thanks for your reply and the links, it helped me clarify things.

IMN logo majestic logo threadwatch logo seochat tools logo