0% found this document useful (0 votes)
18 views134 pages

Functional Dependency & Normalization

The document discusses functional dependency and normalization in databases, explaining various types of functional dependencies such as trivial, non-trivial, transitive, multivalued, fully functional, and partial functional dependencies. It also covers Armstrong's axioms for deducing functional dependencies, attribute closure, equivalence of functional dependencies, and the concept of minimal cover. Additionally, it addresses the issues of insertion, deletion, and update anomalies in database design.

Uploaded by

tupaida
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)
18 views134 pages

Functional Dependency & Normalization

The document discusses functional dependency and normalization in databases, explaining various types of functional dependencies such as trivial, non-trivial, transitive, multivalued, fully functional, and partial functional dependencies. It also covers Armstrong's axioms for deducing functional dependencies, attribute closure, equivalence of functional dependencies, and the concept of minimal cover. Additionally, it addresses the issues of insertion, deletion, and update anomalies in database design.

Uploaded by

tupaida
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/ 134

Functional Dependency

&
Normalization
Functional Dependency
• If 𝛼 ⊆ R and β ⊆ R and if there exist a fd: 𝛼 -> β R
and t1[𝛼] = t2[𝛼], then t1[β] – t2[β] 𝛼 β
a 1
b 2
𝛼 -> β
c 3
𝛼 β d 4
Determinant Dependent
Functional Dependency
• If a functional dependency A -> B in a relation holds and if two tuples having
the same value of attribute A also have the same value for attribute B.

Student
Sid Name Phone State Country Age Fd = { Sid -> Name
1 Ram 9716271721 Haryana India 20 Sid -> Phone
2 Ram 9898291281 Punjab India 19 Sid -> State
Sid -> Country
3 Sugit 7898291981 Rajasthan India 18 State -> Country }
4 Suresh Punjab India 21
Types of Functional Dependency

Fd:
𝛼 -> β

Non-Trivial Transitive Multivalued


Trivial Functional Fully Functional Partial Functional
Functional Functional Functional
Dependency Dependency Dependency
Dependency Dependency Dependency
Trivial Functional Dependency
• In this dependency, a
dependent is always a
subset of the determinant. Roll_No Name Age
101 A 17
102 B 18

• if x -> y and y ⊆ x 103 C 18


Non-Trivial Functional Dependency
• In this dependency, the
dependent is strictly not a
subset of the determinant. Roll_No Name Age
101 A 17
102 B 18

• if x -> y and y ⊄ x 103 C 18


Transitive Functional Dependency
• In this dependency,
dependent is indirectly
dependent on determinant Roll_No Name Dept Build_No
101 A BCA 4
• if x -> y and y -> z then, 102 B MCA 4

x -> z 103 C B.Tech 1


104 D MBA 2
Multivalued Functional Dependency
• In this dependency,
attributes of the dependent
set are not dependent on Roll_No Name Age
each other. 101 A 17
102 B 18
• if x -> {y, z} and there exist 103 C 18
no functional dependency
between y and z
Fully Functional Dependency
• In this dependency, an attribute
or a set of attributes uniquely
determines another attribute or
a set of attributes Roll_No Name Age
101 A 17
102 B 18
• R(x,y,z) and x -> y and x -> z
103 C 18
Partial Functional Dependency
• In this dependency, a non key
attribute depends on a part of
the composite key rather than Roll_No Name Course Instructor
the whole key.
101 A Java P
102 B PHP Q
• R(x,y,z) and x -> z 101 A JS R
103 C Python S
103 C PHP Q
Exercise Problems
R
1. Which FD is valid?
A B C D E
a) A -> BC
a 2 3 4 5
b) DE -> C
2 A 3 4 5
c) C -> DE
a 2 3 6 5
d) BC -> A
a 2 3 6 6
Exercise Problems
R
2. Which FD is valid?
x y z
a) xy -> z && z -> y
1 4 2
b) yz -> x && y -> z
1 5 3
c) yz -> x && x-> z
1 6 3
d) xz -> y && y -> z
3 2 2
Exercise Problems
R
3. Which FD is valid?
A B C
a) A -> B && BC -> A
1 2 4
b) C -> B && CA -> B
3 5 4
c) B -> C && AB -> C
3 7 2
d) A -> C && BC -> A
1 4 2
Armstrong Axioms
• Set of inference rules used to deduce all the functional dependencies on a
relational Database.

Armstrong Axioms

Primary Rule Secondary Rule


Armstrong Axioms
• Primary Rule:

1. Reflexive Rule –
if Y⊆ X, then X -> Y

2. Augmentation Rule –
if X -> Y, then XZ -> YZ

3. Transitive Rule –
if X -> Y and Y -> Z, then X -> Z
Armstrong Axioms
• Secondary Rule:

1. Union Rule –
if X -> Y and X -> Z, then X -> YZ

2. Decomposition Rule –
If X -> YZ, then X -> Y and X -> Z
Armstrong Axioms
• Secondary Rule:

3. Pseudo-transitive Rule –
if X -> Y and WY -> Z, then WX -> Z

4. Composition Rule –
If X -> Y and Z -> W, then XZ -> YW
Attribute Closure / Closure of attribute set
• Closure of an attribute set A can be defined as a set of attributes which can
be functionally determined from it and denoted by A+

Student(Sid, Name, Contact, State, Country, Age)


Sid -> {Name, Contact, State}
{State} -> {Country}
(Sid)+ = {Sid}
= {Sid, Name, Contact, State}
= {Sid, Name, Contact, State, Country}
Attribute Closure / Closure of attribute set
1. Find out Closure

R(A, B, C) A+ = ?
A -> B
B -> C

B+ = ?
Attribute Closure / Closure of attribute set
2. Find out Closure

R(A, B, C, D, E, F) D+ = ?
A -> B
C -> DE
AC -> F
E -> CF (BE)+ = ?
Attribute Closure / Closure of attribute set
3. Find out Closure

R(A, B, C, D, E, F, G) (AC)+ = ?
A -> B
BC -> DE
AEG -> G
E -> CF
Attribute Closure / Closure of attribute set
4. Find out Closure

R(A, B, C, D, E) (B)+ = ?
A -> BC
CD -> E
B -> D
E -> A
Attribute Closure / Closure of attribute set
5. Find out Closure

R(A, B, C, D, E, F) (AB)+ = ?
BC -> C
BC -> AD
D -> E
CF -> B
Attribute Closure / Closure of attribute set
6. Find out Closure

R(A, B, C, D, E, F, G, H) (BCD)+ = ?
A -> BC
CD -> E
E -> C
D -> AEH
ABH -> BD
DH -> BC
Attribute Closure / Closure of attribute set
7. Find out Closure

R(A, B, C, D, E, F, G, H) (B)+ = ?
A -> BC
AB -> D
B-> C
Attribute Closure / Closure of attribute set
8. Consider the relation R with the Now consider the following dependencies:
following information R(A, B, C, D) i) B -> D
ii) A -> C
A B C D iii) ABC -> D
iv) ABD -> C
a b z 1
e b r 1 Which of the following FD is not valid
a d z 1 1. (i) and (ii)
2. (iii) only
e d r 1
3. (iv) only
a f z 2 4. (ii) and (iv) only
a f r 2
Equivalance of Functional Dependency
Problem -1
R(ACDEH)

F: A -> C G: A -> CD
AC -> D E -> AH
E -> AD
E ->H
Equivalance of Functional Dependency
Problem -2
R(PQRS)
X: P -> Q G: P -> QR
Q -> R R -> S
R -> S
Equivalance of Functional Dependency
Problem -3

R(ABC)
F: A -> B G: A -> BC
B -> C B -> A
C -> A C -> A
Equivalance of Functional Dependency
Problem -4
R(VWXYZ)

F: W -> X G: W -> XY
WX -> Y Z -> WX
Z -> WY
Z -> V
Equivalance of Functional Dependency
Problem -5
R(A B C D E)

F: A -> B G: A -> BC
AB -> C D -> AE
D -> AC
D-> E
Minimal Cover or Canonical Cover or Irreducible
Set of Functional Dependency
• Find the redundant element(s).

𝛼 -> β
 Redundancy on the side of 𝛼
 Redundancy on the side of β
 Enter FD is redundant
Minimal Cover or Canonical Cover or Irreducible
Set of Functional Dependency
Problem -1

R(W X Y Z)
X -> W
WZ -> XY
Y -> WZX
Minimal Cover or Canonical Cover or Irreducible
Set of Functional Dependency
Problem -2

R(A B C D)
A -> B
C -> B
D -> ABC
AC -> D
Minimal Cover or Canonical Cover or Irreducible
Set of Functional Dependency
Problem -3

R(v w x y z)
v -> w
vw -> x
y -> vxz
Minimal Cover or Canonical Cover or Irreducible
Set of Functional Dependency
Problem -4

R(P Q R S)
P -> QR
Q -> R
P -> Q
PQ -> R
Minimal Cover or Canonical Cover or Irreducible
Set of Functional Dependency
Problem -5

R(A B C)
A -> BC
B -> AC
C -> AB
Minimal Cover or Canonical Cover or Irreducible
Set of Functional Dependency
Problem -6

R(A B C)
A -> BC
B -> C
A -> B
AB -> C
Minimal Cover or Canonical Cover or Irreducible
Set of Functional Dependency
Problem -7

R(A B C)
A -> B
AB -> C
A -> BC
B -> C
Minimal Cover or Canonical Cover or Irreducible
Set of Functional Dependency
Problem -8

R(P Q R)
P -> QR
PQ -> R
Q -> R
P -> Q
Keys in Database
R
A B C
1 a p
2 b q
3 c q
4 c r
Super Key, Candidate Key, Primary Key
Problem -1

R(A B C D)
A -> BC
Super Key, Candidate Key, Primary Key
Problem -2

R(A B C D)
ABC -> D
AB -> CD
A -> BCD
Super Key, Candidate Key, Primary Key
Problem -3

R(A B C D)
B -> ACD
ACD -> B
Super Key, Candidate Key, Primary Key
Problem -4

R(A B C D)
AB -> C
C-> BD
D -> A
Find Number of Candidate Key
Problem -1

R(A B C D)

A -> B
B-> C
C -> A
Find Number of Candidate Key
Problem -2

R(A B C D)

AB -> CD
D -> A
Find Number of Candidate Key
Problem -3

R(A B C D E F)

AB -> C
C -> D
B -> AE
Find Number of Candidate Key
Problem -4

R(A B C D)

AB -> CD
C -> A
D -> B
Find Number of Candidate Key
Problem -5

R(A B C D E)

AB -> CD
D -> A
BC -> DE
Find Number of Candidate Key
Problem -6

R(W X Y Z)

Z -> W
Y -> XZ
XW -> Y
Find Number of Candidate Key
Problem -7

R(A B C D E F)

AB -> C
DC -> AE
E -> F
Find Number of Candidate Key
Problem -8

R(A B C D E)

CE -> D
D -> B
C -> A
Find Number of Candidate Key
Problem -9

R(A B C D E F G H I J)

AB -> C
AD -> GH
BD -> EF
A -> I
H -> J
Find Number of Candidate Key
Problem -10

R(A B C D E)

A -> B
BC -> E
DE -> A
Find Number of Candidate Key
Problem -11

R(A B C D E)

BC -> ADE
D -> B
Find Number of Candidate Key
Problem -12

R(A B C D E F)

AB -> C
C -> D
D -> BE
E -> F
F -> A
Find Number of Candidate Key
Problem -13

R(A B C D E F)

AB -> C
AC -> B
AD -> E
BC -> A
E -> F
Find Number of Candidate Key
Problem -14

R(A B C D E F G H)

CH -> G
A -> BC
B -> CFH
E -> A
F -> EG
Insertion, Deletion and Update Anomalies
Idea –
• In the table Studentinfo, we have tried Studentinfo
to store entire data about student. Sid Name Age Bcode Bname HOD
Result - 1 A 18 101 CSE XYZ
• Entire branch data of a branch must be 2 B 19 101 CSE XYZ
repeated for every student of the
branch. 3 C 18 101 CSE XYZ
4 D 21 102 ECE PQR
Redundancy –
5 E 20 102 ECE PQR
• When some data is stored multiple
times unnecessarily in a database. 6 F 19 103 ME KLM
Insertion, Deletion and Update Anomalies
Disadvantages –
Studentinfo
Sid Name Age Bcode Bname HOD
1. Insertion, Deletion and Update
1 A 18 101 CSE XYZ
anomalies.
2 B 19 101 CSE XYZ
2. Inconsistency of data
3 C 18 101 CSE XYZ
3. Increasing in database size means
increasing in accessing time. 4 D 21 102 ECE PQR
5 E 20 102 ECE PQR
6 F 19 103 ME KLM
Insertion, Deletion and Update Anomalies
Anomaly –
Studentinfo
• It means the inconsistency occurred in
the relational table during the Sid Name Age Bcode Bname HOD
operations performed on the 1 A 18 101 CSE XYZ
relational table. 2 B 19 101 CSE XYZ
3 C 18 101 CSE XYZ
Anomaly 4 D 21 102 ECE PQR
5 E 20 102 ECE PQR
6 F 19 103 ME KLM
Insertion Deletion Update
Insertion, Deletion and Update Anomalies
Insertion Anomaly –
• Certain data cannot be inserted into Studentinfo
database without the presence of Sid Name Age Bcode Bname HOD
other data.
1 A 18 101 CSE XYZ
2 B 19 101 CSE XYZ
Deletion Anomaly –
• If we delete some rows from the table 3 C 18 101 CSE XYZ
and if any other information which is 4 D 21 102 ECE PQR
required is also deleted from the
database, it is called deletion 5 E 20 102 ECE PQR
anomalies 6 F 19 103 ME KLM
Insertion, Deletion and Update Anomalies
Studentinfo
Sid Name Age Bcode Bname HOD
Update Anomaly –
1 A 18 101 CSE XYZ
• When we update some rows in the
table and if it leads to the 2 B 19 101 CSE XYZ
inconsistency of the table then it is 3 C 18 101 CSE XYZ
called update anomalies.
4 D 21 102 ECE PQR
5 E 20 102 ECE PQR
6 F 19 103 ME KLM
Basic Concept of Normalization
Normalization –
Student
• Normalization is a process of
eliminating redundancy from Sid Name Age Bcode Bname HOD
the system. 1 A 18 101 CSE XYZ
INF 2 B 19 101 CSE XYZ
3 C 18 101 CSE XYZ
2NF
4 D 21 102 ECE PQR
3NF 5 E 20 102 ECE PQR
6 F 19 103 ME KLM
BCNF
Basic Concept of Normalization
Sid Name Age Bcode
1 A 18 101 Student
2 B 19 101 Sid Name Age Bcode Bname HOD
3 C 18 101 1 A 18 101 CSE XYZ
4 D 21 102
2 B 19 101 CSE XYZ
5 E 20 102
6 F 19 103 3 C 18 101 CSE XYZ
4 D 21 102 ECE PQR
Bcode Bname HOD
5 E 20 102 ECE PQR
101 CSE XYZ
102 ECE PQR 6 F 19 103 ME KLM
103 ME KLM
First Normal Form (1NF)
Student
Roll Name Course
• A relation will be in 1NF, if it contains an
101 Ravi COA
atomic value. OS
102 Prakash DBMS
• 1 NF disallows the multi-valued attribute, CN
composite attribute and their combinations.
1 NF

Student
Roll Name Course
101 Ravi COA
101 Ravi OSA
102 Prakash DBMS
102 Prakash CN
Second Normal Form (2NF)
• Relation must be in 1NF.
R(A B C)
• All non-key attributes are fully functional
B -> C
dependent on the primary key.
Second Normal Form (2NF)
R1
R(A B C) A B R
a 1 A B C
B -> C
b 2 a 1 x
a 3 b 2 y
c 3 a 3 2
d 3 c 3 2
c 3
d 3 2
R2
B C c 3 2
1 x
2 y
3 2
Decompose a relation into 2NF
Problem -1
Check out the relation R1 is in 2NF or not? If not decompose it in 2NF.

R(A B C D)

AB -> D
B -> C
Decompose a relation into 2NF
Problem -2
Check out the relation R is in 2NF or not? If not decompose it in 2NF.

R(A B C D E)

AB -> C
D -> E
Decompose a relation into 2NF
Problem -3
Check out the relation R is in 2NF or not? If not decompose it in 2NF.

R(A B C D E)

A -> B
B -> E
C -> D
Decompose a relation into 2NF
Problem -4
Check out the relation R is in 2NF or not? If not decompose it in 2NF.

R(A B C D E F G H I J)

AB -> C
AD -> GH
BD -> EF
A -> I
H -> J
Decompose a relation into 2NF
Problem -5
Check out the relation R is in 2NF or not? If not decompose it in 2NF.

R(A B C D E)

A -> C
B -> DE
Decompose a relation into 2NF
Problem -6
Check out the relation R is in 2NF or not? If not decompose it in 2NF.

R(A B C D E)

ABC -> D
CD -> A
AD -> E
Decompose a relation into 2NF
Problem -7
Check out the relation R is in 2NF or not? If not decompose it in 2NF.

R(A B C D)

AB -> C
BC -> D
Decompose a relation into 2NF
Problem -8
Check out the relation R is in 2NF or not? If not decompose it in 2NF.

R(A B C D)

AB -> CD
B -> C
Decompose a relation into 2NF
Problem -9
Check out the relation R is in 2NF or not? If not decompose it in 2NF.

R(P Q R S T)

PQ -> R
S -> T
Decompose a relation into 2NF
Problem -10
Check out the relation R is in 2NF or not? If not decompose it in 2NF.

R(P Q R S T U V W X Y)

PQ -> R
PS -> VW
QS -> TU
P -> X
W -> Y
Third Normal Form (3NF)
• Relation must be in 2NF.
R(A B C)
• All non-key attributes are fully functional
A -> B
dependent on the primary key.
B -> C
Third Normal Form (3NF)
R1

R(A B C) A B R
a 1
A B C
A -> B b 1
B -> C a 1 x
c 1
d 2 b 1 x
e 2 c 1 x
f 3 d 2 y
g 3
R2
e 2 y
B C f 3 z
1 x g 3 z
2 y
3 2
Third Normal Form (3NF)
R1
A B R
a 1
Every dependency from A B C
b 1
𝛼 -> β a 1 x
c 1
d 2 b 1 x
I. Either 𝛼 is a super
key e 2 c 1 x
II. or β is a prime f 3 d 2 y
attribute. g 3
R2
e 2 y
B C f 3 z
1 x g 3 z
2 y
3 2
Decompose a relation into 3NF
Problem -1

R(A B C D E)

A -> B
B -> E
C -> D
Decompose a relation into 3NF
Problem -2

R(A B C D E F G H I J)

AB -> C
A -> DE
B -> F
F -> GH
D -> IJ
Decompose a relation into 3NF
Problem -3

R(A B C D E)

AB -> C
B -> D
D -> E
Decompose a relation into 3NF
Problem -4

R(A B C D E F G H I J)

AB -> C
AD -> GH
BD -> EF
A -> I
H->J
Boyce-Codd Normal Form (BCNF)
• Relation must be in 3NF.
R(A B C)
• X should be a super key for every functional
AB -> C
dependency (FD) X−>Y in a given relation.
C -> B
Boyce-Codd Normal Form (BCNF)
R1
R(A B C) A C R
a x A B C
AB -> C b y
C -> B a 1 x
c z
b 2 y
c w
d w c 2 z
c w c 3 w
R2
d 3 w
C B
c 3 w
x 1
y 2
z 2
w 3
BCNF Decomposition
• Find out all Candidate Key of relation

• Make a new relation with FD that does not satisfy BCNF rules and remove
RHS attributes from the original relation. Updated original relation is also
take into the consideration.

• If Candidate Key is not a part of any relation, then make new relation with
candidate key.
Decompose a relation into BCNF
Problem -1

R(A B C D E F G H I J)

AB -> C
BD -> EF
AD -> GH
A -> I
H ->J
Decompose a relation into BCNF
Problem -2

R(A B C D E)

A -> B
A -> C
D -> C
D -> E
Decompose a relation into BCNF
Problem -3

R(A B C D E)

A -> B
B -> E
C -> D
Decompose a relation into BCNF
Problem -4

R(A B C D E F G H I J)

AB -> C
A -> DE
B -> F
F -> GH
D -> IJ
Decompose a relation into BCNF
Problem -5

R(A B C D E)

AB -> C
B -> D
D -> E
Find the Normal Form and Decompose into
Required Normal Form
Problem -1

R(A B C D E F G H)

AB -> C
A -> DE
F -> GH
Find the Normal Form and Decompose into
Required Normal Form
Problem -2

R(A B C D E)

CE -> D
D -> B
C -> A
Find the Normal Form and Decompose into
Required Normal Form
Problem -3

R(A B C D E F)

AB -> C
DC -> AE
E -> F
Find the Normal Form and Decompose into
Required Normal Form
Problem -4

R(A B C D E F G H I)

AB -> C
BD -> EF
AD -> GH
A -> I
Find the Normal Form and Decompose into
Required Normal Form
Problem -5

R(A B C D E)

AB -> CD
D -> A
BC -> DE
Find the Normal Form and Decompose into
Required Normal Form
Problem -6

R(A B C D E)

BC -> ADE
D -> B
Find the Normal Form and Decompose into
Required Normal Form
Problem -7

R(V W X Y Z)

X -> YV
Y -> Z
Z -> Y
VW > X
Find the Normal Form and Decompose into
Required Normal Form
Problem -8

R(A B C D E F)

ABC -> D
ABD -> E
CD -> F
CDF > B
BF -> D
Find the Normal Form and Decompose into
Required Normal Form
Problem -9

R(A B C)

A -> B
B -> C
C -> A
Find the Normal Form and Decompose into
Required Normal Form
Problem -10

R(A B C D E F G H I J)

AB -> C
A -> DE
B -> F
D -> IJ
F -> GH
Find the Normal Form and Decompose into
Required Normal Form
Problem -11

R(A B C D E F)

A -> BCDEF
BC -> ADEF
DEF -> ABC
Find the Normal Form and Decompose into
Required Normal Form
Problem -12

R(A B C)

AB -> C
C -> A
Find the Normal Form and Decompose into
Required Normal Form
Problem -13

R(A B C D E)

A -> B
BC -> E
DE -> A
Find the Normal Form and Decompose into
Required Normal Form
Problem -14

R(A B C D E)

AB -> CD
D -> A
BC -> DE
Find the Normal Form and Decompose into
Required Normal Form
Problem -15

R(W X Y Z)

Z -> W
Y -> XZ
XW -> Y
Lossless Decomposition / Non-additive Join
Decomposition

R1
R
A C A B C D
• This property guarantees that the extra 1 a 1 a p x
or less tuple generation problem does 2 b
not occur after decomposition. 2 b q y
R2

D
x
y
Lossless Decomposition / Non-additive Join
Decomposition
Mandatory Properties: -
R1
R
• If a relation R is decomposed into two
relations R1 and R2, then it will be A C A B C D
loss-less iff 1 a 1 a p x
2 b
2 b q y
1. attr(R1) ∪ attr(R2) = attr(R)
R2
2. attr(R1) ∩ attr(R2) ≠ ∅
D
3. attr(R1) ∩ attr(R2) -> attr(R1)
x
Or
y
attr(R1) ∩ attr(R2) -> attr(R2)
Lossless Decomposition / Non-additive Join
Decomposition R
A B C D
1 a p x
Mandatory Properties: -
2 b q y
• If a relation R is decomposed into two R1 R2
relations R1 and R2, then it will be A B C D
loss-less iff 1 a p x
2 b q y
1. attr(R1) ∪ attr(R2) = attr(R)
2. attr(R1) ∩ attr(R2) ≠ ∅ R=R1 x R2
A B C D
3. attr(R1) ∩ attr(R2) -> attr(R1)
1 a p x
Or
1 a q y
attr(R1) ∩ attr(R2) -> attr(R2)
2 b p x
2 b q y
Lossless Decomposition / Non-additive Join
Decomposition R

R1 A B C R2

A B 1 a p B C
Mandatory Properties: -
2 b q a p
• If a relation R is decomposed into two 1 a
relations R1 and R2, then it will be 2 b 3 a r b q
loss-less iff 3 a a r

R=R1 ⨝ R2
1. attr(R1) ∪ attr(R2) = attr(R)
2. attr(R1) ∩ attr(R2) ≠ ∅ A B C

3. attr(R1) ∩ attr(R2) -> attr(R1) 1 a p


1 a r
Or
2 b q
attr(R1) ∩ attr(R2) -> attr(R2)
3 a P
3 a r
Lossless Decomposition / Non-additive Join
Decomposition
Problem- 1 R
A B C D E
1. R1(AB), R2(CD) a 122 1 p w
2. R1(ABC), R2(DE) b 234 2 q x
3. R1(ABC),R2(CDE) a 568 1 r y

4. R1(ABCD),R2(ACDE) c 347 3 s 2

5. R1(ABCD),R2(DE)
6. R1(ABC),R2(BCD),R3(DE)
Lossless Decomposition / Non-additive Join
Decomposition
Problem- 2

R(V,W,X,Y,Z)

Z-> Y 1. R1(VWX), R2(XYZ)


Y -> Z 2. R1(VW), R2(YZ)
X -> YV 3. R1(VWX), R2(YZ)
VW -> X 4. R1(VW), R2(WXYZ)
Lossless Decomposition / Non-additive Join
Decomposition
Problem- 3

R(A B C D)

A-> B
B -> C
C -> D
D -> B

R1(AB), R2(BC), R3(BD)


Lossless Decomposition / Non-additive Join
Decomposition
Problem- 4

Consider a relation schema R ( A , B , C , D ) with the functional dependencies A → B and


C → D. Determine whether the decomposition of R into R1 ( A , B ) and R2 ( C , D ) is
lossless or lossy.
Lossless Decomposition / Non-additive Join
Decomposition
Problem- 5

Consider a relation schema R ( A , B , C , D ) with the following functional dependencies-


A→B
B→C
C→D
D→B
Determine whether the decomposition of R into R1 ( A , B ) , R2 ( B , C ) and R3 ( B , D )
is lossless or lossy.
Dependency Preserving Decomposition
• If a table R having FD set F, is decomposed into two tables R1 and R2
having FD set F1 and F2, then
F1 ⊆ F+
F2 ⊆ F+
________
(F1 ∪ F2) = F+
Dependency Preserving Decomposition
Problem- 1

R(A B C)

A-> B
B -> C
C -> A

R1(AB), R2(BC)
Dependency Preserving Decomposition
Problem- 2

R(A B C D)

AB-> CD
D -> A

R1(AD), R2(BCD)
Dependency Preserving Decomposition
Problem- 3

R(A B C)

A-> B
B -> C

R1(AC), R2(BC)
Dependency Preserving Decomposition
Problem- 4
R(A B C D) is decomposed into R1(A,B.C), R2(C,D) and F={B-> C, AC -> D},
What dependency do hold in R1 and R2?
Homework
Problem-1
Consider the following relation schema R given by
R = {Ssn, Ename, Pnumber, Pname, Plocation, Hours }
R is decomposed into three sub-schema namely R1, R2 and R3
R1 = {Ssn, Ename}
R2 = {Pnumber, Pname, Plocation}
R3 = {Ssn, Pnumber, Hours}
Explain with justification, whether or not, the above decomposition is lossless.
Homework
Problem-2
R(A, B, C, D) and A -> BC, B-> E, CE -> D in R. Find the candidate key of R
Homework
Problem-3
Consider the following relation R = {A, B, C, D, E, F, G, H, I} and the functional
dependency is given below –
F ={A -> B, C-> DE, F-> G, B -> GH, AF -> C, E -> I}
Determine the current normal form of the given relation. Decompose it upto BCNF.
Homework
Problem-4
Find the candidate keys for the following relation R : R(A,B,C,D,E,H)
and F={A -> B, BC -> D, E -> C, D -> a}
Homework
Problem-5
For the relation schema R(A, B, C, D, E, F, G, H, I, J) and set of FDs F = {ABD ->
E, AB -> G, B -> F, C -> J, CJ -> I, G -> H}
Find the irreducible set of functional dependency.
Homework
Problem-6
For the relation R1(L, M, N, P) and R2(M, O)
a) Is the above decomposition is lossless join decomposition?
b) Is the above decomposition is dependency preserving?
Homework
Problem-7
Let R(j, K, L) be a relation schema with the following dependencies –
F = {JK -> L, L -> K}
a) Which are the candidate keys for R?
b) Find L+
c) Find whether j -> K holds or not
Homework
Problem-8
Consider the relation schema R (A, B, C, D, E, G) with set F of functional
dependencies {A -> B, BC -> D, D -> E, D -> G}
Find the closure of F.
Homework
Problem-9
Find the minimal cover of F = {A -> BC, AC ->D, D -> B, AB -> D}
Homework
Problem-10
What is the highest NF of each of the following relations?
R1(A, B, C) with FDs are A-> B, A -> C, C -> B
R2(A, B, C, D) with FDs are A -> BC, CD -> B

You might also like