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 > Vehicle table normalization

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-28-11, 15:15
Eiolon Eiolon is offline
Registered User
 
Join Date: Jan 2006
Posts: 26
Vehicle table normalization

I see two scenarios, but not sure which is proper:

Scenario 1:

Table: Years
ID
Year

Table: Makes
ID
Make

Table: Models
ID
Model

Table: Series
ID
Series

Table: Vehicles
ID
YearID
MakeID
ModelID
SeriesID


Scenario 2:


Table: Years
ID
Year

Table: Makes
ID
YearID
Make

Table: Models
ID
YearID
MakeID
Model

Table: Vehicle
ID
YearID
MakeID
ModelID
Series

The goals is to have people narrow down their vehicle selection by starting with year, then make, the model then series. Thoughts?
Reply With Quote
  #2 (permalink)  
Old 04-28-11, 15:17
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,246
well it's be a cracking start to make an effort at your coursework before posting here
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 04-28-11, 15:21
Eiolon Eiolon is offline
Registered User
 
Join Date: Jan 2006
Posts: 26
What do you mean? I am not in school. I am just trying to learn on my own...
Reply With Quote
  #4 (permalink)  
Old 04-28-11, 15:31
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by Eiolon View Post
Table: Years
ID
Year
this always makes me plotz with laughter

do yourself a favour and stop applying ids to everything
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 04-28-11, 15:41
Eiolon Eiolon is offline
Registered User
 
Join Date: Jan 2006
Posts: 26
Sigh...

Okay, like I said, I've just been trying to learn on my own. All I have are Internet tutorials and books telling me to assign unique ID's to everything. I'd love to learn the "proper" way, whichever that is, since what I keep reading doesn't seem to be it.
Reply With Quote
  #6 (permalink)  
Old 04-28-11, 16:00
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by Eiolon View Post
... tutorials and books telling me to assign unique ID's to everything.
whatever you've been reading, it's wrong

one does ~not~ assign ids to everything willy-nilly

you should assign a surrogate key (for that's what it's called) only when a suitable natural key does not exist

suitable often means that the key can be used in other tables as a foreign key without becoming unwieldy

what's a natural key? any column, or combination of columns, that already exist within the data, that uniquely identify each row

more than this, i cannot tell you now, without turning this thread into a tutorial, which i'm not prepared to do

do some research on natural vs surrogate key -- it's a contentious issue, to be sure, but anyone who says you should apply a surrogate key to every table is deluded
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 04-28-11, 16:14
Eiolon Eiolon is offline
Registered User
 
Join Date: Jan 2006
Posts: 26
Thank you. I have been reading SQL books for awhile and surprisingly its the first time I have heard of the two key types. I have heard primary and foreign but that's it. I will read more into it.

By the way, your book Simply SQL, is it written for beginners such as myself, or for more experienced SQL users?
Reply With Quote
  #8 (permalink)  
Old 04-28-11, 16:20
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
definitely for beginners

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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