My new site won't go up for another month or so.  It will look very 
professional - I'm great with flash, css, and programming (javascript 
for example)..

I just learned a ton about the Normal Forms... Great stuff.. I even used 
it to normalize a table to 3NF

For instance, my Rushing Offenses table had the following fields

Rank
Name
Games
Carries
Net
Avg
TDs
Ydspgm
Wins
Losses
Ties
DateTime

I was pulling separate data each week and adding it to the table.  So, 
let's say I had 4 weeks worth of data for 120 teams.  Normalizing it, I 
found the following issues:

1NF:

Are there any duplicative columns? No. Do we have a primary key? Not 
really, the built in ID is irrelevant in this particular table.  So, I 
changed things around a bit.

Two Tables:

table 'teams'

team_id
name

table 'rushing_offense'
team_id
rank
games
Carries
Net
Avg
TDs
Ydspgm
Wins
Losses
Ties
DateTime

This normalized it for 1nf.

2NF:

Are there any subsets of data that apply to multiple rows?  No, so the 
above meets 2NF as well.

3NF:

Are all of the columns fully dependent upon the primary key? No, so it 
does not meet 3NF.

Rank, Avg, and Ydspgm are not fully dependent on the primary key.  I can 
get the rank from sorting Ydspgm.  I can find the Avg by doing simple 
math (dividing net/carries) and I can find Ydspgm by (dividing 
net/games).  Therefore, these don't need to go into my table either.

So, I ended up with 2 final tables: (3NF qualified)

table 'teams'

team_id
name

table 'rushing_offense'

team_id
games
Carries
Net
TDs
Wins
Losses
Ties
DateTime

It was fun understanding that and accomplishing this tiny little task. 
I had heard but never truly understood what normalization meant until 
today.  Thanks for the heads up.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to