Professional Documents
Culture Documents
1
Chapter 3 : Objectives
What normalization is and what role it plays in
database design
About the normal forms 1NF, 2NF, 3NF, BCNF, and
4NF
How normal forms can be transformed from lower
normal forms to higher normal forms
That normalization and E-R modeling are used
concurrently to produce a good database design
That some situations require denormalization to
generate information efficiently
2
What is Normalization ?
A technique for producing a set of relations
with desirable properties (minimum data
redundancy), given the data requirements of
an enterprise.
3
Why Normalization ?
Main objective in developing a logical data
model for relational database systems is to
create an accurate representation of the
data, its relationships, and constraints.
To achieve this objective, must identify a
suitable set of relations.
A relation can be normalized to a specific
form to prevent possible occurrence of
update anomalies.
4
Why Normalization ?
As normalization proceeds, relations become
progressively more restricted (stronger) in
format and also less vulnerable to update
anomalies.
5
Why Normalize ?
An ER Model is not always available as a
starting point for design
To reduce redundant data in existing design
To increase integrity of data and stability of
design
To identify missing tables, columns and
constraints
6
Why Normalization ?
SID Name Grade Course# Text Major Dept
S1 Joseph A CIS800 b1 CIS CIS
S1 Joseph B CIS820 b2 CIS CIS
S1 Joseph A CIS872 b5 CIS CIS
S2 Alice A CIS800 b1 CS MCS
S2 Alice A CIS872 b5 CS MCS
S3 Tom B CIS800 b1 Acct Acct
S3 Tom B CIS872 b5 Acct Acct
S3 Tom A CIS860 b1 Acct Acct
7
Update Anomalies
A poorly designed relation contains redundant data.
8
First Normal Form
All key attributes defined
No repeating groups in table
All attributes dependent on
primary key
9
Example : 1NF
Example : FIRST(S#,STATUS,CITY,P#,QTY)
- Suppliers supply certain quantities of parts and are located in some city.
- Status of the supplier is determined by the location (city) of that supplier.
10
Example : 1NF
S# STATUS CITY P# QTY
S1 20 London P1 300
S1 20 London P2 200
S1 20 London P3 400
S1 20 London P4 200
S1 20 London P5 100
S1 20 London P6 100
S2 10 Paris P1 300
S2 10 Paris P2 400
S3 10 Paris P2 200
S4 20 London P2 200
S4 20 London P4 300
S4 20 London P5 400
11
Example : 1NF
To overcome the above anomalies in the
relation FIRST , FIRST has to be
decomposed into smaller relations
(projections).
=> Decomposition
12
Non-loss Decomposition
In a good decomposition
The join of decomposed relations restores the original
relation.
Decomposed relations can be maintained
independently.
13
Non-loss Decomposition
Rissanen's Rules:
14
Functional Dependency
Given two attributes X and Y of a relation R, Y
is functionally dependent on X iff each X-
value in R has associated with it exactly one
Y-value in R(if two tuples agree on their X-
value, they also agree on their Y-value).
X Y
15
Functional Dependency
Example: List all FDs in FIRST
FD Diagram of FIRST:
S# CITY
QTY
STATUS
P#
16
Properties of FDs
17
Properties of FDs
An FD could be trivial or non-trivial
An FD is trivial
if it is impossible for it not to be satisfied
if the RHS is a subset of the LHS
18
Full Functional Dependency :
19
Transitive Functional Dependency
X Y, Y Z and X Z
20
UNNORMALIZED FORM (UNF)
Examples :
Is FIRST Unnormalized ?
Is relation SCH given below Unnormalized ?
21
UNF to 1NF
Remove repeating group by entering appropriate data into the empty columns of
rows containing repeating data (‘flattening’ the table).
22
FIRST NORMAL FORM (1NF)-
revisited
A relation R is in 1NF iff all attribute domains
contain atomic values only.
Example :
FIRST is in 1NF
FIRST has update anomalies
23
FIRST NORMAL FORM (1NF)
FD diagram of FIRST:
QTY
S#
CITY
P#
STATUS
24
SECOND NORMAL FORM (2NF)
A relation R is in 2NF iff it is in 1NF and every non-
prime-key attribute is fully functionally dependent on
the primary key.
A non-prime-key attribute does not belong to any
candidate key.
Is FIRST in 2NF ?
How to normalize FIRST into 2NF ?
Remove all partial (or non-full) dependencies from
FIRST by decomposing FIRST into two smaller
relations SP and SECOND
25
SECOND NORMAL FORM (2NF)
Is the decomposition of First into SP and
SECOND good ?
SP(S#,P#,QTY)
SECOND(S#,CITY,STATUS)
26
SECOND NORMAL FORM (2NF)
FD Diagram of SP and SECOND
S# CITY
S#
QTY
P#
STATUS
SECOND is in 2NF
SECOND has update anomalies
27
THIRD NORMAL FORM(3NF)
Is SECOND(S#,CITY,STATUS) in 3NF ?
28
THIRD NORMAL FORM(3NF)
How to normalize SECOND into 3NF ?
29
30
THIRD NORMAL FORM(3NF)
FD Diagram of SC and CS
31
Help me Codd !
32
THIRD NORMAL FORM(3NF)
Relation R(A,B,C,D) given below is in 3NF
Still has Update Anomalies !!
33
Example :
Example: TEACH (Student, Course, Instructor)
INSTRUCTOR
COURSE
Is TEACHES in 3NF ?
Does TEACHES have update anomalies ?
What happens if (Student, Instructor) is chosen as
the Primary key!
35
BOYCE/CODD NORMAL FORM
37
Why Denormalize ?
Normalization is the process of putting one fact in
one appropriate place. This optimizes updates at the
expense of retrievals.
39
Denormalization
Denormalization
40
An Example of Denormalization
Consider a relation :
Contact (Name, Street, Zip, City, Province)
PK of Contact ?
Is Contact in 3NF ?
41
Example of Denormalization(contd)
42