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 > Database normalization

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-25-10, 09:38
pistonhead pistonhead is offline
Registered User
 
Join Date: Mar 2010
Posts: 2
Database normalization

I'm storing tourist attractions in a database. Each attraction has the following:

AttractionID
Name
Latitude
Longitude
Country
Info
Picture
PictureHeight
PictureWidth

How could I normalise this database?

Currently I have a PictureTable, LocationTable, NameTable, and InfoTable. However, the primary key in each of these tables is the AttractionID, and I know this is wrong.

Help please?

Thanks
Reply With Quote
  #2 (permalink)  
Old 03-25-10, 09:55
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by pistonhead View Post
How could I normalise this database?
only the picture width and height are wrong, as they depend on the picture and not on the attraction

so a separate picture table is warranted, and the primary key would be a unique identifier for each picture, with a foreign key in the attractions table

your other tables (LocationTable, NameTable, and InfoTable) are not necessary
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 03-25-10, 10:04
pistonhead pistonhead is offline
Registered User
 
Join Date: Mar 2010
Posts: 2
Quote:
Originally Posted by r937 View Post
only the picture width and height are wrong, as they depend on the picture and not on the attraction

so a separate picture table is warranted, and the primary key would be a unique identifier for each picture, with a foreign key in the attractions table

your other tables (LocationTable, NameTable, and InfoTable) are not necessary
Thankyou.

Some attractions are in the same country though. Would this mean I need a seperate 'Country' table, with CountryID, which is a foreign key in the AttractionsTable?
Reply With Quote
  #4 (permalink)  
Old 03-25-10, 10:18
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by pistonhead View Post
Would this mean I need a seperate 'Country' table, with CountryID, which is a foreign key in the AttractionsTable?
no it wouldn't

have you ever seen an employees table, with firstname and lastname columns?

just because two employees have 'John" as firstname, doesn't mean you automatically need to pull firstname out of the employees table and set up a foreign key to a "firstnames" table

normalization means does each non-key attribute fully depend on the entire primary key

so if i give you the value of an attractionid, can you unambiguously pull out the value of the country for that particular attraction? yes
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 03-25-10, 10:19
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Not for normalisation.
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