Normalization
Lecture 3
Dr. Marwa Hussien
Summary of Normal Forms Based on Primary
Keys and Corresponding Normalization
Normal Rule Normalization
Form
First(1NF) Relation should have no multivalued Form new relations for each multivalued
attributes or nested relations. attribute or nested relation.
Second(2NF) For relations where primary key Decompose and set up a new relation for each
contains multiple attributes, no nonkey partial key with its dependent attribute(s). Make
attribute should be functionally sure to keep a relation with the original primary
dependent on a part of the primary key. key and any attributes that are fully functionally
dependent on it.
Third(3NF) Relation should not have a nonkey Decompose and set up a relation that includes
attribute functionally determined by the nonkey attribute(s) that functionally
another nonkey attribute (or by a set of determine(s) other nonkey attribute(s).
nonkey attributes). That is, there
should be no transitive dependency of
a nonkey attribute on the primary key.
2
General Normal Form Definitions (For Multiple Keys)
• The above definitions consider the primary key only.
• The following more general definitions take into account relations
with multiple candidate keys.
• Any attribute involved in a candidate key is a prime attribute.
• All other attributes are called non-prime attributes.
3
General Definition of
2NF (For Multiple
Candidate Keys)
• A relation schema R is in second
normal form (2NF) if every non-
prime attribute A in R is fully
functionally dependent on every
key of R.
• The FD County_name → Tax_rate
violates 2NF.
• So, second normalization
converts LOTS into LOTS1
(Property_id#, County_name,
Lot#, Area, Price) LOTS2 (
County_name, Tax_rate)
4
General Definition
of Third Normal
Form
• Definition: Superkey of relation
schema R - a set of attributes S
of R that contains a key of R.
• A relation schema R is in third
normal form (3NF) if whenever a
FD X → A holds in R, then
either:
• (a) X is a superkey of R, or
• (b) A is a prime attribute of
R
• LOTS1 relation violates 3NF
because Area → Price ; and Area
is not a superkey in LOTS1.
5
Third Normal Form
• NOTE:
• In X -> Y and Y -> Z, with X as the primary key, we consider this a problem
only if Y is not a candidate key.
• When Y is a candidate key, there is no problem with the transitive
dependency .
• E.g., Consider EMP (SSN, Emp#, Salary ).
• Here, SSN -> Emp# -> Salary and Emp# is a candidate key.
6
BCNF (Boyce-Codd Normal Form)
• A relation schema R is in Boyce-Codd Normal Form (BCNF) if
whenever an FD X → A holds in R, then X is a superkey of R. “Even if
A is a prime attribute”
• Each normal form is strictly stronger than the previous one
• Every 2NF relation is in 1NF
• Every 3NF relation is in 2NF
• Every BCNF relation is in 3NF
• There exist relations that are in 3NF but not in BCNF.
• Hence BCNF is considered a stronger form of 3NF.
• The goal is to have each relation in BCNF (or 3NF)
Boyce-Codd
normal form
Problems
1. Given a relation R( A, B, C, D) and Functional Dependency set
FD = { AB → CD, B → C }, determine whether the given R is in 2NF? If
not convert it into 2 NF.
• R (A ,B ,C ,D )
Problem
2. Given a relation R( P, Q, R, S, T, U, V, W, X, Y) and Functional
Dependency set FD = { PQ → R, P → ST, Q → U, U → VW, and S → XY},
determine whether the given R is in 3NF? If not convert it into 3 NF.
• R( P, Q, R, S, T, U, V, W, X, Y)
Problem
3. Given a relation R( X, Y, Z) and Functional Dependency set FD = { XY
→ Z and Z → Y }, determine whether the given R is in BCNF? If not
convert it into BCNF.
• R( X, Y, Z)