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 > General > Database Concepts & Design > Which of the following two is the best?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-04-09, 13:53
joehansen joehansen is offline
Registered User
 
Join Date: Nov 2009
Posts: 5
Which of the following two is the best?

Hey everyone,

We have the following two tables in the database:
photo {photonum, title, filename, filesize}
website {websitenum, name}

To capture which photos belong to which websites, I have two possible approaches:

Approach 1: Create another table
photowebsite {photnum, websitenum}

Pros:
1. Traditional database design. Will satisfy the Normal Forms.

Cons:
1. Queries involving a website will always involve a join operation.

Approach 2. Add a boolean field to the photo table for each website.
photo {photonum,.... , website1, website2 }

Pros:
1. Queries will not have a join operation and will be faster than Approach 2.

Cons:
1. Adding a new website will involve creating a new field and hence the database must be shutdown.
2. The number of fields will increase with the increase in the number of websites.

However, we right now have only 4 websites and I am wondering if I should go with the 2nd Approach. The only thing that's hold me back is that the number of websites can definitely increase in future.

Can Database Gurus on this forum help me choose the right design!

Thank you!
Joe
Reply With Quote
  #2 (permalink)  
Old 12-04-09, 15:10
MarkATrombley MarkATrombley is offline
Registered User
 
Join Date: Jul 2009
Location: Michigan
Posts: 125
Approach 1 is best. Joins aren't slow as long as you have primary keys and indexes.
Reply With Quote
  #3 (permalink)  
Old 12-04-09, 15:34
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Option 1, unless your goal is to be the butt of jokes for the DBA who inherits your project after you are gone.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #4 (permalink)  
Old 12-04-09, 16:10
joehansen joehansen is offline
Registered User
 
Join Date: Nov 2009
Posts: 5
Quote:
Originally Posted by blindman View Post
Option 1, unless your goal is to be the butt of jokes for the DBA who inherits your project after you are gone.
Thanks for putting that subtly, blindman! It taught me a good lesson that shortcuts are not worth it.
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