Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2005
    Location
    UK
    Posts
    2

    Unanswered: DB design check for a Company Directory web site

    Hi finally thought I'd start posting now I have something that needs checking

    I am designing a web site that lists many differnet companies in different catagories and sub catagories. I have two tables explained below:

    tbl_cats

    catID (autonumber)
    catName (primary key)


    tbl_Company

    catName (primary key)
    subcatname
    directoryID (autonumber)
    CompName
    ContactName
    CompAddress
    etc...

    tbl_Cats is just for the Industry Catagories on the site

    tbl_Company is where the details for a company are stored


    In tbl_cats each catagory (catName) requires a unique number and also in tbl_Company the directoryID is the unique number for that company.

    Does all this look ok and is the primary key set correctly or would you recommned something better? i.e. am I making some awful mistakes so far?

    Cheers

    Andy

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    It MIGHT be ok depending on your business rules...

    One quick note, catName is not the primary key for tbl_company, directoryID is. catName is a foriegn key. Also, link by ID's not names. that's the entire point of having an id. catName and subcatName would be better represented as cat_id, subcat_id

    Whether or not it's kosher to store the category and subcategory in tbl_Company depends on how flexible you need to be. Is there ever a chance you may want to assign more than one subcategory to a company? If so, those need to be stored in a seperate table. If there will ALWAYS NO MATTER WHAT be exactly one category and one subcategory for each company, than this layout will be fine.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Dec 2005
    Location
    UK
    Posts
    2

    Red face

    Great point Teddy, thanks! But whats the relationship between the three tables?

    Sorry I'm now lost??

    So I would now have as my three tables:

    tbl_cats

    cat_ID (autonumber + primary key)
    cat_Name


    NEW table:
    tbl_subcats
    subcat_ID (autonumber + primary key)
    subcat_Name


    tbl_Company

    cat_Name
    subcat_Name
    directory_ID (autonumber and primary key)
    CompName
    ContactName
    CompAddress
    etc...

    Thanks

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Try one table for categories, one table for companies, and one table for company categories...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

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