Download - Normalization Venu
-
8/6/2019 Normalization Venu
1/19
Database Normalization
A. Venu Gopal
22 Feb 2011
Himansu IT Services
-
8/6/2019 Normalization Venu
2/19
Overview Introductions
The Normal Forms Primary Key
Relationships and Referential Integrity
When NOT to Normalize Real World Exercise
Resources
Himansu IT Services
-
8/6/2019 Normalization Venu
3/19
Why Normalize? Flexibility
Structure supports many ways to look at the data
Data Integrity Modification Anomalies
Deletion
Insertion
Update
Efficiency
Eliminate redundant data and save space
Himansu IT Services
-
8/6/2019 Normalization Venu
4/19
Normalization Defined In relational database design, the process of
organizing data to minimize duplication.
Normalization usually involves dividing adatabase into two or more tables and definingrelationships between the tables.
The objective is to isolate data so that additions,
deletions, and modifications of a field can be madein just one table and then propagated through the
rest of the database via the defined relationships.- Webopedia, http://webopedia.internet.com/TERM/n/normalization.html
Himansu IT Services
-
8/6/2019 Normalization Venu
5/19
Another Definition "Normalization" refers to the process of
creating an efficient, reliable, flexible,
and appropriate "relational" structure forstoring information. Normalized datamust be in a "relational" data structure.
- Reid Software Development, http://www.accessdatabase.com/normalize.html
Himansu IT Services
-
8/6/2019 Normalization Venu
6/19
The Normal Forms A series of logical steps to take to
normalize data tables
First Normal Form Second
Third
Boyce Codd Theres more, but beyond scope of this
Himansu IT Services
-
8/6/2019 Normalization Venu
7/19
First Normal Form (1NF) All columns (fields) must be atomic
Means : no repeating items in columns
OrderDate Customer Items11/30/1998 Joe Smith Hammer, Saw, Nails
OrderDate Customer Item1 Item2 Item311/30/1998 Joe Smith Hammer Saw Nails
Solution: make a separate table for each set of
attributes with a primary key (parser, append query)Customers
CustomerID
Name
Orders
OrderID
Item
CustomerID
OrderDate Himansu IT Services
-
8/6/2019 Normalization Venu
8/19
Second Normal Form ( NF) In 1NF and every non-key column is fullydependent on the (entire) primary key Means : Do(es) the key field(s) imply the rest of the fields? Do we
need to know both OrderID and Item to know the Customer andDate? Clue: repeating fields
Solution: Remove to a separate table (Make Table)
OrderID Item CustomerID OrderDate1 Hammer 1 11/30/19981 Saw 1 11/30/19981 Nails 1 11/30/1998
OrderDetails
OrderID
Item
Orders
OrderID
CustomerID
OrderDateHimansu IT Services
-
8/6/2019 Normalization Venu
9/19
Third Normal Form (3NF) In NF and every non-key column is mutually
independent
means : Calculations
Solution: Put calculations in queries and forms
Item Quantity Price TotalHammer $10 $ 0Saw 5 $40 $ 00Nails 8 $1 $8
OrderDetailsOrderID
Item
Quantity
Price
Putexpressionintextcontrolorin query:
=Quantity * Price
Himansu IT Services
-
8/6/2019 Normalization Venu
10/19
2/16/98 10MGS 4042/16/98 10
Boyce-Codd Form (3NF) - Examples
A more restricted version of 3NF (known asBoyce-Codd Normal Form) requires that thedeterminant of every functional dependency ina relation be a key - for every FD: X => Y, X isa key
Consider the following relation:STU-MAJ-ADV (Student-Id, Major, Advisor)
Advisor => Major, but Advisor is not a key Boyce-Codd Normal Form for above:
STU-ADV (Student-Id, Advisor)ADV-MAJ (Advisor, Major)
Kumar Madurai: http://www.mgt.buffalo.edu/courses/mgs/404/mfc/lecture4.ppt
-
8/6/2019 Normalization Venu
11/19
Primary Key Unique Identifier for every row in the
table
Integers vice Text to save memory, increasespeed
Can be composite
Surrogate is best bet!
Meaningless, numeric column acting asprimary key in lieu of something like SSN orphone number - (both can be reissued!)
Himansu IT Services
-
8/6/2019 Normalization Venu
12/19
Relationships One to many to enforce Referential Integrity
Two foreign
keys make acomposite primary
key and relate
many to many
tables
A lookup table - it
doesnt reference
any others
Himansu IT Services
-
8/6/2019 Normalization Venu
13/19
Table Prefixes Aid Development
First, well get replace text PK with number
The Items table is a look up with tlkp prefix tlkp lookup table (no foreign keys)
OrderDetails is renamed trelOrderItem arelational table trel relational (or junction or linking)
two foreign keys make a primary
tblOrders
OrderID
CustomerID
OrderDate
OrderDetails
OrderID
Item trelOrderItem
OrderID
ItemID
tlkpItems
ItemID
ItemName
Himansu IT Services
-
8/6/2019 Normalization Venu
14/19
Referential Integrity Every piece of foreign key data has a
primary key on the one site of the relationship No orphan records. Every child has a parent
Cant delete records from primary table if in related table
Benefits - Data Integrity and Propagation If update fields in main table, reflected in all queries
Cant add a record in related table without adding it to main
Cascade Delete: If delete record from primary table, allchildren deleted - use with care! Better idea to archive
Cascade Update: If change the primary key field, will changeforeign key
Himansu IT Services
-
8/6/2019 Normalization Venu
15/19
When Not to Normalize
Want to keep tables simple so user can maketheir own queries Avoid processing multiple tables
Archiving Records If No need to perform complex queries or resurrect
Flatten and store in one or more tables
Testing shows Normalization has poorer
performance Sounds Like field example
Can also try temp tables produced from Make Table queries
Himansu IT Services
-
8/6/2019 Normalization Venu
16/19
Real World - School DataStudent Student Previous Current
Last First Parent 1 Parent 2 Teacher Teacher
Smith Renee Ann Jones Theodore Smith Hamil BurkeMills Lucy Barbara Mills Steve Mills Hamil Burke
Jones Brendan Jennifer Jones Stephen Jones Hamil Burke.
Street Address City State Postal Code Home Phone
5551 Private Hill Annandale Virginia 22003- (703) 323-08934902 Acme Ct Annandale Virginia 22003- (703) 764-5829
5304 Gains Street Fairfax Virginia 22032- (703) 978-1083 .
First Year Last Year Age
Program Enrolled Attended Birthday inSept Map Coord Notes
PF / 0 0 6/25/93 5 22 A-3PF 96/97 0 8/14/93 5 21 F-3PH 96/97 0 6/13/94 4 21 A-4
Himansu IT Services
-
8/6/2019 Normalization Venu
17/19
One Possible Design
Himansu IT Services
-
8/6/2019 Normalization Venu
18/19
Books Access97 Developers Handbook Litwin,Getz & Gilbert Chapter 4
Access and SQL Server Developers Handbook
Viescas, Gunderloy and Chipman Chapter 2
Access97 Expert Solutions Lezynski Chapter 10
Himansu IT Services
-
8/6/2019 Normalization Venu
19/19
Internet Papers http://www.mtjeff.com/~calvin/devhbook/databasedesign.html
http://www.swin.edu.au/infotech/subjects/bt220/bt220s1.html
http://www.bus.okstate.edu/lhammer/AISweb/Normaliz.htmhttp://www.inetspace.com/database.html
Slides http://www.mgt.buffalo.edu/courses/mgs/404/mfc/lecture4.ppt
http://www.state.sd.us/people/colink/datanorm.htm
http://www.cba.nau.edu/morgan-j/class/subtop2_3/sld001.htm
R
acoosin Solutions