SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    1,963
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quick DB decision question

    I have a companies table (about 190.000) with the usual info (name, address, etc). Some of these companies will become advertisers. There are some advertising related fields like (advert_type(pay_per_click, etc), period, budget etc) What do you guys and girls think is best? To have those fields in the companies table or to create a separate table advertising table with company_id as foreign key.

    I personally think that I should go for the second option since a company could choose for more than one advert_type. Or is there maybe another way, I didn't think of and someone would choose to use?

    I look forward to hear your opinion.

  2. #2
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if a company can have many advert types then you will need a second table, otherwise a single table would be ok.

  3. #3
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    1,963
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just what I thought myself, but it's never a bad idea to hear some other opinions as well. Thanks

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,015
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by donboe View Post
    Or is there maybe another way, I didn't think of and someone would choose to use?
    yes, there is, but it has the drawback that if you search on all companies that have a certain ad type, for example, it is forced to use a table scan, hence your query is as slow as cold glue
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by donboe View Post
    Just what I thought myself, but it's never a bad idea to hear some other opinions as well. Thanks
    you're welcome


Bookmarks

Posting Permissions

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