0% found this document useful (0 votes)
49 views

Fundamentals of Database Systems: (Normalization - II)

The document discusses database normalization forms including first normal form (1NF), second normal form (2NF), third normal form (3NF), and Boyce-Codd normal form. 1NF requires that attributes have atomic (non-decomposable) domains. Higher normal forms add additional constraints to reduce redundant or anomalous data. The document provides examples of relations and how to normalize them to various normal forms through decomposition and attribute separation.

Uploaded by

thecoolguy96
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Fundamentals of Database Systems: (Normalization - II)

The document discusses database normalization forms including first normal form (1NF), second normal form (2NF), third normal form (3NF), and Boyce-Codd normal form. 1NF requires that attributes have atomic (non-decomposable) domains. Higher normal forms add additional constraints to reduce redundant or anomalous data. The document provides examples of relations and how to normalize them to various normal forms through decomposition and attribute separation.

Uploaded by

thecoolguy96
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Fundamentals of Database Systems


[Normalization – II]

Malay Bhattacharyya

Assistant Professor

Machine Intelligence Unit


Indian Statistical Institute, Kolkata
January, 2021
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

1 First Normal Form

2 Second Normal Form

3 Third Normal Form

4 Boyce-Codd Normal Form


Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

First normal form

The domain (or value set) of an attribute defines the set of values
it might contain.

A domain is atomic if elements of the domain are considered to be


indivisible units.

Company Make
Company Make
Maruti WagonR, Ertiga
Maruti WagonR, Ertiga
Honda City
Honda City
Tesla RAV4
Tesla, Toyota RAV4
Toyota RAV4
BMW X1
BMW X1
Only Company has atomic domain None of the attributes have atomic domains
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

First normal form

Definition (First normal form (1NF))


A relational schema R is in 1NF iff the domains of all attributes in
R are atomic.

The advantages of 1NF are as follows:


It eliminates redundancy
It eliminates repeating groups.

Note: In practice, 1NF includes a few more practical constraints


like each attribute must be unique, no tuples are duplicated, and
no columns are duplicated.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

First normal form

The following relation is not in 1NF because the attribute Model is


not atomic.
Company Country Make Model Distributor
Maruti India WagonR LXI, VXI Carwala
Maruti India WagonR LXI Bhalla
Maruti India Ertiga VXI Bhalla
Honda Japan City SV Bhalla
Tesla USA RAV4 EV CarTrade
Toyota Japan RAV4 EV CarTrade
BMW Germany X1 Expedition CarTrade

We can convert this relation into 1NF in two ways!!!


Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

First normal form

Approach 1: Break the tuples containing non-atomic values into


multiple tuples.

Company Country Make Model Distributor


Maruti India WagonR LXI Carwala
Maruti India WagonR VXI Carwala
Maruti India WagonR LXI Bhalla
Maruti India Ertiga VXI Bhalla
Honda Japan City SV Bhalla
Tesla USA RAV4 EV CarTrade
Toyota Japan RAV4 EV CarTrade
BMW Germany X1 Expedition CarTrade
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

First normal form

Approach 2: Decompose the relation into multiple relations.

Make Model Distributor


Company Country Make
WagonR LXI Carwala
Maruti India WagonR
WagonR VXI Carwala
Maruti India Ertiga
WagonR LXI Bhalla
Honda Japan City
Ertiga VXI Bhalla
Tesla USA RAV4
City SV Bhalla
Toyota Japan RAV4
RAV4 EV CarTrade
BMW Germany X1
X1 Expedition CarTrade
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Why data dependencies are so important?


Choose the best keyset for the locks given below.

Locks Keyset 1 Keyset 2 Keyset 3


¶ ¶ ¶
L1 K1 K1 K3
¶ ¶ ¶
L2 K1 K2 K4
¶ ¶ ¶
L3 K1 K3 K5
¶ ¶ ¶
L3 K1 K4 K5
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Why data dependencies are so important?


Choose the best keyset for the locks given below.

Locks Keyset 1 Keyset 2 Keyset 3


¶ ¶ ¶
L1 K1 K1 K3
¶ ¶ ¶
L2 K1 K2 K4
¶ ¶ ¶
L3 K1 K3 K5
¶ ¶ ¶
L3 K1 K4 K5

Keyset 1 is not appropriate because a single key can open


multiple locks.
Keyset 2 is not appropriate because the same lock can be
opened with multiple keys.
Keyset 3 is the best option!!!
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Functional dependency

A subset K of A(R), the attributes in a relation schema R, is a


superkey of R if t1 6= t2, for all pairs of tuples t1, t2 ∈ R, implies
t1[K ] 6= t2[K ]. This means no two tuples in R may have the same
value on attribute set K .
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Functional dependency

A subset K of A(R), the attributes in a relation schema R, is a


superkey of R if t1 6= t2, for all pairs of tuples t1, t2 ∈ R, implies
t1[K ] 6= t2[K ]. This means no two tuples in R may have the same
value on attribute set K .

The notion of functional dependency generalizes the notion of


superkey. Consider a relation schema R, and let X ⊆ R and
Y ⊆ R. The functional dependency X → Y holds on schema R if

t1[X ] = t2[X ],

in any legal relation r (R), for all pairs of tuples t1 and t2 in r , then

t1[Y ] = t2[Y ].
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Superkey versus functional dependency

A B C A B C
1 1 2 1 1 2
1 2 2 1 1 2
2 3 1 2 3 1
3 3 1 3 3 1
AB is a superkey AB is not a superkey
AB → C holds AB → C holds

A B C
1 1 2
NOT POSSIBLE 1 1 2
2 3 1
3 3 1
AB is a superkey AB is not a superkey
AB → C does not hold AB → C does not hold
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Partial dependency

The partial dependency X → Y holds in schema R if there is a


Z ⊂ X such that Z → Y .

We say Y is partially dependent on X if and only if there is a


proper subset of X that satisfies the dependency.

Note: The dependency A → B implies if the A values are same,


then the B values are also same.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Second normal form

Definition (Second normal form (2NF))


A relational schema R is in 2NF if each attribute A in R satisfies
one of the following criteria:
1 A is part of a candidate key.
2 A is not partially dependent on a candidate key.

In other words, no non-prime attribute (not a part of any candidate


key) is dependent on a proper subset of any candidate key.

Note: A candidate key is a superkey for which no proper subset is


a superkey, i.e. a minimal superkey.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Second normal form

The following relation is in 1NF but not in 2NF because Country


is a non-prime attribute that partially depends on Company, which
is a proper subset of the candidate key {Company, Make, Model,
Distributor}.

Company Country Make Model Distributor


Maruti India WagonR LXI Carwala
Maruti India WagonR VXI Carwala
Maruti India WagonR LXI Bhalla
Maruti India Ertiga VXI Bhalla
Honda Japan City SV Bhalla
Tesla USA RAV4 EV CarTrade
Toyota Japan RAV4 EV CarTrade
BMW Germany X1 Expedition CarTrade

We can convert this relation into 2NF!!!


Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Second normal form

Company Country Make Model Distributor


Maruti India WagonR LXI Carwala
Maruti India WagonR VXI Carwala
Maruti India WagonR LXI Bhalla
Maruti India Ertiga VXI Bhalla
Honda Japan City SV Bhalla
Tesla USA RAV4 EV CarTrade
Toyota Japan RAV4 EV CarTrade
BMW Germany X1 Expedition CarTrade

{Company, Make, Model, Distributor} → Country


Company → Country (Violating 2NF)
Note: Country is partially dependent on {Company, Make, Model,
Distributor}.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Second normal form

Approach: Decompose the relation into multiple relations.

Company Make Model Distributor


Company Country Maruti WagonR LXI Carwala
Maruti WagonR VXI Carwala
Maruti India
Maruti WagonR LXI Bhalla
Honda Japan
Maruti Ertiga VXI Bhalla
Tesla USA
Honda City SV Bhalla
Toyota Japan
Tesla RAV4 EV CarTrade
BMW Germany
Toyota RAV4 EV CarTrade
BMW X1 Expedition CarTrade

Note: Each attribute in the left relation is either a part of the


candidate key {Company} or having full functional dependency on
it and in the right relation is a part of the candidate key
{Company, Make, Model, Distributor}.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Functional dependency
Armstrong’s axioms:
Reflexivity property: If X is a set of attributes and Y ⊆ X ,
then X → Y holds. (known as trivial functional dependency)
Augmentation property: If X → Y holds and γ is a set of
attributes, then γX → γY holds.
Transitivity property: If both X → Y and Y → Z holds,
then X → Z holds.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Functional dependency
Armstrong’s axioms:
Reflexivity property: If X is a set of attributes and Y ⊆ X ,
then X → Y holds. (known as trivial functional dependency)
Augmentation property: If X → Y holds and γ is a set of
attributes, then γX → γY holds.
Transitivity property: If both X → Y and Y → Z holds,
then X → Z holds.
Other properties:
Union property: If X → Y holds and X → Z holds, then
X → YZ holds.
Decomposition property: If X → YZ holds, then both
X → Y and X → Z holds.
Pseudotransitivity property: If X → Y and γY → Z holds,
then X γ → Z holds.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Closure of functional dependencies (FDs)

We can find F + , the closure of a set of FDs F , as follows:

Initialize F + with F
repeat
for each functional dependency f = X → Y ∈ F + do
Apply reflexivity and augmentation properties on f and
include the resulting functional dependencies in F +
end for
for each pair of functional dependencies f1 , f2 ∈ F + do
if f1 and f2 can be combined together using the transitivity
property then
Include the resulting functional dependency in F +
end if
end for
until F + does not further change
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Closure of functional dependencies (FDs) – An example

Consider a relation R = <UVWXYZ> and the set of FDs = {U →


V, U → W, WX → Y, WX → Z, V → Y}. Let us compute some
non-trivial FDs that can be obtained from this.

By applying the augmentation property, we obtain


1 UX → WX (from U → W)
2 WX → WXZ (from WX → Z)
3 WXZ → YZ (from WX → Y)
By applying the transitivity property, we obtain
1 U → Y (from U → V and V → Y)
2 UX → Z (from UX → WX and WX → Z)
3 WX → YZ (from WX → WXZ and WXZ → YZ)
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Closure of attribute sets

We can find A+ , the closure of a set of attributes A, as follows:

Initialize A+ with A
repeat
for each functional dependency f = X → Y ∈ F + do
if X ⊆ A+ then
A+ ← A+ ∪ Y
end if
end for
until A+ does not further change

Note: The closure is defined as the set of attributes that are


functionally determined by A under a set of FDs F .
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Closure of attribute sets

The usefulness of finding attribute closure is as follows:


Testing for superkey
– Compute A+ and check if R ⊆ A+
Testing functional dependencies
– To check if an FD X → Y holds, just check if Y ⊆ X+
– Same for checking if X → Y is in F + for a given F
Computing closure of F
– For each A ⊆ A(R), we find the closure A+ , and for each
S ⊆ A+ , we output a functional dependency A → S
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Closure of attribute sets – An example

Consider a relation R = <UVWXYZ> and the set of FDs = {U →


V, U → W, WX → Y, WX → Z, V → Y}. Let us compute UX+ ,
i.e., the closure of UX.

Initially UX+ = UX
Then we have UX+ = UVX (as U → V and U ⊆ UX)
Then we have UX+ = UVWX (as U → W and U ⊆ UVX)
Then we have UX+ = UVWXY (as WX → Y and WX ⊆
UVWX)
Finally, we have UX+ = UVWXYZ (as WX → Z and WX ⊆
UVWXY)

Note: The closure of UX covers all the attributes in R.


Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Decomposition of a relation

If a relation is not in a desired normal form, it can be decomposed


into multiple relations such that each decomposed relation satisfies
the required normal form.

Suppose a relation R consists of a set of attributes


A(R) = {A1 , A2 , . . . , An }. A decomposition of R replaces R by a
set of (two or more) relations {R1 , . . . , Rm } such that both the
following conditions hold:
∀i : A(Ri ) ⊂ A(R)
A(R1 ) ∪ · · · ∪ A(Rm ) = A(R)
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Decomposition criteria

The decomposition of a relation might aim to satisfy different


criteria as listed below:
Preservation of the same relation through join (lossless-join)
Dependency preservation
Repetition of information
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Preservation of the same relation through join

X Y Z
. x1 y1 z1 &
x1 y2 z2
X Y X Z X Z Y Z
x1 y1 x1 z1 x1 z1 y1 z1
x1 y2 x1 z2 x1 z2 y2 z2

& . & .

X Y Z
x1 y1 z1 X Y Z
x1 y1 z2 x1 y1 z1
x1 y2 z1 x1 y2 z2
x1 y2 z2
Lossy-join decomposition Lossless-join decomposition
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Testing for lossless-join decomposition

A decomposition of R into {R1 , R2 } is lossless-join, iff


A(R1 ) ∩ A(R2 ) → A(R1 ) or A(R1 ) ∩ A(R2 ) → A(R2 ) in F + .

Consider the example of a relation R = <UVWXY> and the set of


FDs = {U → VW, WX → Y, V → X, Y → U}.
Note that, the decomposition R1 = <UVW> and R2 = <WXY>
is not lossless-join because R1 ∩ R2 = W, and W is neither a key
for R1 nor for R2 .
However, the decomposition R1 = <UVW> and R2 = <UXY> is
lossless-join because R1 ∩ R2 = U, and U is a key for R1 .
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Dependency preservation

The decomposition of a relation R with respect to a set of FDs F


replaces R with a set of (two or more) relations {R1 , . . . , Rm } with
FDs {F1 , . . . , Fm } such that Fi is the subset of dependencies in F +
(the closure of F) that include only the attributes in Ri .

The decomposition is dependency preserving iff (∪i Fi )+ = F + .

Note: Through dependency preserving decomposition, we want to


minimize the cost of global integrity constraints based on FDs’
(i.e., avoid big joins in assertions).
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Testing for dependency preserving decomposition

Consider the example of a relation R = <XYZ>, having the key


X, and the set of FDs = {X → Y, Y → Z, X → Z}.
Note that, the decomposition R1 = <XY> and R2 = <XZ> is
lossless-join but not dependency preserving because F1 = {X →
Y} and F2 = {X → Z} incur the loss of the FD {Y → Z},
resulting into (F1 ∪ F2 )+ 6= F + .
However, the decomposition R1 = <XY> and R2 = <YZ> is
lossless-join and also dependency preserving because
F1 = {X → Y } and F2 = {Y → Z }, satisfying (F1 ∪ F2 )+ = F + .
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Third normal form

Definition (Third normal form (3NF))


A relational schema R is in 3NF if for every non-trivial functional
dependency X → A, one of the following statements is true:
1 X is a superkey of R.
2 A is a part of some key for R.

Note: A superkey is a set of one or more attributes that can


uniquely identify an entity in the entity set.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Third normal form

The following relation is in 2NF but not in 3NF because Country


is a non-prime attribute that depends on Company, which is again
a non-prime attribute. Notably, the key in this relation is {PID}.

PID Company Country Make Model Distributor


P01 Maruti India WagonR LXI Carwala
P02 Maruti India WagonR VXI Carwala
P03 Maruti India WagonR LXI Bhalla
P04 Maruti India Ertiga VXI Bhalla
P05 Honda Japan City SV Bhalla
P06 Tesla USA RAV4 EV CarTrade
P07 Toyota Japan RAV4 EV CarTrade
P08 BMW Germany X1 Expedition CarTrade

We can convert this relation into 3NF!!!


Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Third normal form

PID Company Country Make Model Distributor


P01 Maruti India WagonR LXI Carwala
P02 Maruti India WagonR VXI Carwala
P03 Maruti India WagonR LXI Bhalla
P04 Maruti India Ertiga VXI Bhalla
P05 Honda Japan City SV Bhalla
P06 Tesla USA RAV4 EV CarTrade
P07 Toyota Japan RAV4 EV CarTrade
P08 BMW Germany X1 Expedition CarTrade

PID → {Company, Country, Make, Model, Distributor}


Company → Country (Violating 3NF)
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Third normal form

Approach: Decompose the relation into multiple relations.

PID Company Make Model Distributor


Company Country P01 Maruti WagonR LXI Carwala
P02 Maruti WagonR VXI Carwala
Maruti India
P03 Maruti WagonR LXI Bhalla
Honda Japan
P04 Maruti Ertiga VXI Bhalla
Tesla USA
P05 Honda City SV Bhalla
Toyota Japan
P06 Tesla RAV4 EV CarTrade
BMW Germany
P07 Toyota RAV4 EV CarTrade
P08 BMW X1 Expedition CarTrade

Note: Each attribute in the left relation is a part of the superkey


{Company, Country} and in the right relation is a part of the
candidate key {PID}.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Boyce-Codd normal form

Definition (Boyce-Codd normal form (BCNF))


A relational schema R is in BCNF if for every non-trivial functional
dependency X → A, X is a superkey of R.

Note: A superkey is a set of one or more attributes that can


uniquely identify an entity in the entity set.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Boyce-Codd normal form

The following relation is in 3NF but not in BCNF because the


attribute Distributor, which depends on the non-key attribute
ShopID, is a part of the key. Notably, the key in this relation is
{Company, Make, Model, Distributor}.

Company Make Model Distributor ShopID


Maruti WagonR LXI Carwala S1
Maruti WagonR VXI Carwala S1
Maruti WagonR LXI Bhalla S2
Maruti Ertiga VXI Bhalla S3
Honda City SV Bhalla S4
Tesla RAV4 EV CarTrade S5
Toyota RAV4 EV CarTrade S5
BMW X1 Expedition CarTrade S6
BMW X1 Expedition CarTrade S7

We can convert this relation into BCNF!!!


Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Boyce-Codd normal form

Company Make Model Distributor ShopID


Maruti WagonR LXI Carwala S1
Maruti WagonR VXI Carwala S1
Maruti WagonR LXI Bhalla S2
Maruti Ertiga VXI Bhalla S3
Honda City SV Bhalla S4
Tesla RAV4 EV CarTrade S5
Toyota RAV4 EV CarTrade S5
BMW X1 Expedition CarTrade S6
BMW X1 Expedition CarTrade S7

{Company, Make, Model, Distributor} → ShopID


ShopID → Distributor (Violating BCNF)
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Boyce-Codd normal form

Approach: Decompose the relation into multiple relations.

Company Make Model ShopID


Distributor ShopID Maruti WagonR LXI S1
Carwala S1 Maruti WagonR VXI S1
Bhalla S2 Maruti WagonR LXI S2
Bhalla S3 Maruti Ertiga VXI S3
Bhalla S4 Honda City SV S4
CarTrade S5 Tesla RAV4 EV S5
CarTrade S6 Toyota RAV4 EV S5
BMW X1 Expedition S6

Note: Each attribute in the left relation depends on the superkey


ShopID.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Decomposition into BCNF – An algorithm

Result := {R} and flag := FALSE


Compute F +
while NOT flag do
if There is a schema Ri ∈ Result that is not in BCNF then
Let X → Y be a non-trivial functional dependency that
holds on Ri such that (X → Ri ) ∈/ F + and X ∩ Y = φ.
Result := (Result − Ri ) ∪ (Ri − Y ) ∪ (X , Y ) // This is
simply decomposing R into R − Y and XY provided
X → Y in R violates BCNF
else
flag := TRUE
end if
end while
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Decomposition into BCNF – An algorithm

Result := {R} and flag := FALSE


Compute F +
while NOT flag do
if There is a schema Ri ∈ Result that is not in BCNF then
Let X → Y be a non-trivial functional dependency that
holds on Ri such that (X → Ri ) ∈/ F + and X ∩ Y = φ.
Result := (Result − Ri ) ∪ (Ri − Y ) ∪ (X , Y ) // This is
simply decomposing R into R − Y and XY provided
X → Y in R violates BCNF
else
flag := TRUE
end if
end while

Note: This decomposition process ensures lossless property.


Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Decomposition into BCNF – Example I

Consider a relation R = <ABCDE> having the functional


dependencies {A → BC, C → DE}.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Decomposition into BCNF – Example I

Consider a relation R = <ABCDE> having the functional


dependencies {A → BC, C → DE}.
Solution: The attribute closures provide A+ = ABCDE, B+ = B,
C+ = CDE, D+ = D, and E+ = E. Hence, A is the key of R.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Decomposition into BCNF – Example I

Consider a relation R = <ABCDE> having the functional


dependencies {A → BC, C → DE}.
Solution: The attribute closures provide A+ = ABCDE, B+ = B,
C+ = CDE, D+ = D, and E+ = E. Hence, A is the key of R.
Note that, the functional dependency A → BC does not violate
BCNF but C → DE does violate. By applying C → DE, we
decompose R and obtain <ABC> and <CDE>.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Decomposition into BCNF – Example I

Consider a relation R = <ABCDE> having the functional


dependencies {A → BC, C → DE}.
Solution: The attribute closures provide A+ = ABCDE, B+ = B,
C+ = CDE, D+ = D, and E+ = E. Hence, A is the key of R.
Note that, the functional dependency A → BC does not violate
BCNF but C → DE does violate. By applying C → DE, we
decompose R and obtain <ABC> and <CDE>.
Now both <ABC> (A is the key) and <BDP> are in BCNF (C is
the key).
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Decomposition into BCNF – Example II

Suppose a relation R = <ABCD> is given with the


functional dependencies {AB → C, B → D, C → A}.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Decomposition into BCNF – Example II

Suppose a relation R = <ABCD> is given with the


functional dependencies {AB → C, B → D, C → A}.
Solution: The attribute closures provide A+ = A, B+ = BD, C+
= AC, D+ = D, AB+ = ABCD, and BC+ = ABCD. Hence, AB
and BC are the keys of R. Note that, the functional dependency
AB → C does not violate BCNF but B → D and C → A do
violate. By applying B → D, we decompose R and obtain <ABC>
and <BD>.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Decomposition into BCNF – Example II

Suppose a relation R = <ABCD> is given with the


functional dependencies {AB → C, B → D, C → A}.
Solution: The attribute closures provide A+ = A, B+ = BD, C+
= AC, D+ = D, AB+ = ABCD, and BC+ = ABCD. Hence, AB
and BC are the keys of R. Note that, the functional dependency
AB → C does not violate BCNF but B → D and C → A do
violate. By applying B → D, we decompose R and obtain <ABC>
and <BD>.
Now <BD> is in BCNF (B is the key) but not <ABC>. The
functional dependency C → A violates BCNF. By applying C → A,
we further decompose <ABC> and obtain <BC> and <CA>.
Now <BD>, <BC> and <CA> are all in BCNF.
Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Decomposition into BCNF – Example II

Suppose a relation R = <ABCD> is given with the


functional dependencies {AB → C, B → D, C → A}.
Solution: The attribute closures provide A+ = A, B+ = BD, C+
= AC, D+ = D, AB+ = ABCD, and BC+ = ABCD. Hence, AB
and BC are the keys of R. Note that, the functional dependency
AB → C does not violate BCNF but B → D and C → A do
violate. By applying B → D, we decompose R and obtain <ABC>
and <BD>.
Now <BD> is in BCNF (B is the key) but not <ABC>. The
functional dependency C → A violates BCNF. By applying C → A,
we further decompose <ABC> and obtain <BC> and <CA>.
Now <BD>, <BC> and <CA> are all in BCNF.

Note: This BCNF decomposition does not preserve dependencies.


Outline First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form

Comments

Note that
BCNF is stronger than 3NF – if a schema R is in BCNF then
it is also in 3NF.
3NF is stronger than 2NF – if a schema R is in 3NF then it is
also in 2NF.
2NF is stronger than 1NF – if a schema R is in 2NF then it is
also in 1NF.

You might also like