Normalization Notes
Normalization Notes
use http://www.guru99.com/database-
normalization.html
Why do we normalize?
free of update anomalies (problems)
o if I update (change, delete or edit), I shouldn’t have to throughout the
table
tables are smaller
save space
o there may be more records! But less overall data since repeated less
Functional Dependence
Column B is functionally dependent on column A
o Each value for A is associated with exactly one value of B
A functionally determines B
o Column B is functionally dependent on another column A (or collection
of columns) when each value for A in the database is associated with
exactly one value of B
The only way to determine the functional dependenices that exist is to
examine the user’s polices
Keys
Column A (or a collection of columns) is the primary key for a relation R
o Property 1: all columns in R are functionally dependent on A
o Property 2: no subcollection of columns in A also have Property 1
Candidate key: column(s) on which all columns in table are functionally
dependent
Alternate keys: candidate keys not chosen as primary key
Column(s) A is the primary key if all other columns are functionally
dependent on A and no subcollection of columns in A also have this
property
1NF Example
Unnormalized Normalized
Orders(OrderNum, OrderDate, PartNum, NumOrdered)
(dates are all wrong - typo)
Notice that if I made ONE change in a record, I would have to find OTHERS to
change as well!!
o Example, what if I needed to change the Gas Range’s part number to
something new. It’d have to go through ALL of the records and change
them!!
o No no!!
o So let’s break it down so if I make a change, it will be made DB wide.
Converting to 2NF
o Table must FIRST be in 1NF
o Dependency Diagrams in Normalization
arrows indicate all functional dependencies
Arrows above boxes: normal dependencies
Arrows below boxes: partial dependencies
dependencies are formed by logic
Orders(OrderNum, OrderDate)
Part (PartNum, Description)
OrderLine(OrderNum, PartNum, NumOrdered, QuotedPrice)
Third Normal Form (3NF)
2NF tables may still contain problems
tables may have wasted space and Redundancy
could also have the same update anomalies and redundancy as before!!
so we look for Determinants:
o column(s) that determines another column
o Its only determinants are candidate keys
Correction procedure
1. For each determinant that is not a candidate key, remove from table the
columns that depend on this determinant
2. Create new table containing all columns from the original table that depend
on this determinant
3. Make determinant the primary key of new table
Customer Table Normalized to 3NF
Conversion to 4NF
Overall Idea