Professional Documents
Culture Documents
L112 PPT IVSem
L112 PPT IVSem
L112 PPT IVSem
Lecture 12
Normalization
NORMAL FORMS
The normal forms based on FDs are rst normal form (1NF),
second normal form (2NF), third normal form (3NF), and
Boyce-Codd normal form (BCNF).
These
Th
forms
f
have
h
increasingly
i
i l restrictive
t i ti requirements:
i
t
Every relation in BCNF is also in 3NF,
every relation in 3NF is also in 2NF, and every relation in
2NF is in 1NF.
1NF
A relation
is in first normal form if every field contains only atomic
values that is,
values,
is not lists or sets
sets.
This requirement is implicit in our defition of the relational
model.
Although some of the ne
newer
er database s
systems
stems are
relaxing this requirement
2NF is mainly of historical interest.
3NF and
d BCNF are important
i
t t from
f
a database
d t b
design
d i
standpoint.
Slide No:L3-1
Normal Forms
Returning
g to the issue of schema refinement,, the first
question to ask is whether any refinement is needed!
If a relation is in a certain normal form (BCNF, 3NF etc.), it is
known that certain kinds of problems are avoided/minimized.
avoided/minimized
This can be used to help us decide whether decomposing the
relation will help.
Role
R l off FDs
FD in
i detecting
d t ti
redundancy:
d d
Consider a relation R with 3 attributes, ABC.
No FDs hold: There is no redundancy here.
Given A B: Several tuples could have the same A value,
and if so, theyll all have the same B value!
solution: decompose
p
the relation
EMP_PROJ2 (SSN, PNO, HOURS, ENAME, PNAME)
LOC (PNO, PLOCATION)
y2 ?
Example Decomposition
Decompositions should be used only when needed.
SNLRWH has FDs S SNLRWH and R W
Second FD causes violation of 3NF; W values repeatedly
associated
i d with
i h R values.
l
Easiest
E i
way to fix
fi this
hi is
i to
create a relation RW to store these associations, and to
remove W from the main schema:
i.e., we decompose SNLRWH into SNLRH and RW
(r)
(r) = r
X >< Y
It
I is
i always
l
true that
h
r
( )
(r)
()
(r)
< hold!
Y
In general, the other direction Xdoes >
not
If it does, the
decomposition
p
is lossless-join.
j
Definition extended to decomposition into 3 or more relations
in a straightforward way.
It is essential that all decompositions used to deal with
redundancy be lossless! (Avoids Problem (2).)
A
1
4
7
B
2
5
2
A
1
4
7
1
7
C
3
6
8
B
2
5
2
2
2
C
3
6
8
8
3
A
1
4
7
B
2
5
2
B
2
5
2
C
3
6
8
And vice-versa!
vice versa! (Example?)
Slide No. L4-7
SDP,
To deal with SD
P, decompose
into
CSJDQV.
To deal with J S, decompose CSJDQV into JS and
CJDQV
Q
In this case
case, adding JPC to the collection of relations
gives us a dependency preserving decomposition.
JPC tuples stored only for checking FD! (Redundancy!)
Slide No. L4-9