07 Normalization-NDN
07 Normalization-NDN
07 Normalization-NDN
07 Normalization
CII1J3 Database Modelling
2
Learning Outcomes
Students can create database modeling using E-R model,
relational model, and normalization correctly
3
Topics
Steps in Normalization
1st Normalization
2nd Normalization
3rd Normalization
Intro
4
1. First normal form Any multivalued attributes (also called repeating groups) have been
removed, so there is a single value (possibly null) at the intersection of each row and column
of the table.
2. Second normal form Any partial functional dependencies have been removed (i.e., nonkey
attributes are identified by the whole primary key).
3. Third normal form Any transitive dependencies have been removed (i.e., nonkey attributes
are identified by only the primary key).
4. Boyce-Codd normal form Any remaining anomalies that result from functional
dependencies have been removed (because there was more than one possible primary key
for the same nonkeys).
5. Fourth normal form Any multivalued dependencies have been removed.
6. Fifth normal form Any remaining anomalies have been removed.
Example
7
• For a simple illustration, we use a customer invoice from Pine Valley Furniture Company
8
A relation is in first normal form (1nF) if the following two constraints both
apply:
1. There are no repeating groups in the relation (thus, there is a single fact at
the intersection of each row and column of the table).
2. A primary key has been defined, which uniquely identifies each row in the
relation.
Remove Repeating Group
12
Repeating Group
Relation with no repeating group
13
Determine FD & Select the Candidate Key
14
There are four determinants in INVOICE, and their functional dependencies are the following:
• OrderID → OrderDate, CustomerID, CustomerName, CustomerAddress
• CustomerID → CustomerName, CustomerAddress
• ProductID → ProductDescription, ProductFinish, ProductStandardPrice
• OrderID, ProductID → OrderedQuantity
From the four determinants we can infer that:
• OrderID, ProductID → OrderDate, CustomerID, CustomerName, CustomerAddress,
ProductDescription, ProductFinish, ProductStandardPrice, OrderedQuantity
As you can see, the only candidate key for INVOICE is the composite key consisting of the
attributes OrderID and ProductID (because there is only one row in the table for any
combination of values for these attributes).
Relation in 1NF with CK
15
Candidate Key
16
1. Create a new relation for each primary key attribute (or combination of
attributes) that is a determinant in a partial dependency. That attribute is the
primary key in the new relation.
2. Move the nonkey attributes that are only dependent on this primary key
attribute (or attributes) from the old relation to the new relation.
Relation in 2NF (no partial dependencies)
21
22
You can easily remove transitive dependencies from a relation by means of a three-step
procedure:
1. For each nonkey attribute (or set of attributes) that is a determinant in a relation, create a
new relation. That attribute (or set of attributes) becomes the primary key of the new
relation.
2. Move all of the attributes that are functionally dependent only on the primary key of the
new relation from the old to the new relation.
3. Leave the attribute that serves as a primary key in the new relation in the old relation to
serve as a foreign key that allows you to associate the two relations.
Removing transitive dependencies
26
into
Relation in 3NF (no transitive dependencies)
27
Relational schema for invoice data
28
Customer Order
PK CustomerID PK OrderID
CustomerName OrderDate
CustomerAddress FK CustomerID
Product OrderLine
PK ProductID PK FK OrderID
ProductDescription PK FK ProductID
ProductFinish OrderedQuantity
ProductStandardPrice
29
Advanced Normalization:
Boyce-Codd Normal Form
Definition & Constraint
30
3NF relation:
Based on 3NF result, INVOICE relations already in BCNF, because every determinant is a candidate key.
Relation in 3NF but not in BCNF
32
Functional dependencies in
STUDENT ADVISOR
2-step process
33
FAILURE DECOMPOSITION
37
Reference