Unit 2 Functional - Dependency-2
Unit 2 Functional - Dependency-2
Unit 2 Functional - Dependency-2
29/10/22 1
Functional dependency
2
Functional Dependencies Example
Employee Id
Employee Id Name
Name
t1 112 Satish CC JJ
Satish
112 Satish C J
t2
|= Employee Id Name
29/10/22 3
Functional Dependency Examples
29/10/22 4
Consider this table
29/10/22 5
Inference Rules.
29/10/22 6
Inference Rules.
1. IR1. (Reflexive) If Y subset-of X, then X Y
2. IR2. (Augmentation) If X Y, then XZ YZ
3. IR3. (Transitive) If X Y and Y Z, then X Z
4. IR4. (Decomposition): If X YZ, then X Y and
XZ
5. IR5. (Union): If X Y and X Z, then X YZ
29/10/22 7
Trivial functional dependency
8
Closure of a set of attributes
9
Algorithm for computing X+
10
Finding closure of a set of attributes (Example)
R(A, B, C, G, H, I)
F = {A B, A C, CG H, CG I, B H}
A+ = ?
A+ = A
Since A B so A+ = AB
Since A C so A+ = ABC
Consider CG H, CG is not a subset of A+ so A+ remains
unaltered
Consider CG I, CG is not a subset of A+ so A+ remains
unaltered
Consider B H, B is a subset of A+ so A+ = ABCH.
Find out (AG)+ and (CG)+ .
11
Finding a Key (K) for R
12
Example 1
Answer: AB
13
Example 2
R(A, B, C, D, E, G, H) &
F = {A B, B ACE, C BGD, G DH}.
14
Example 3
R(A, B, C, D) &
F = {A B, B C, C BD}.
Ans. A
15
Example 4
R(A, B, C, D, E) &
F = {A B, B A, B C, D A}.
Find out key(s) of R.
[Ans. DE]
Solution:
A+= ABC ≠ R so A cannot be a key.
B+ = BAC ≠ R, so B cannot be a key.
D+ = DABC ≠ R and so D cannot be a key.
(DE)+ = DEABC = R and so DE is a key of R.
16
Example
17
MINIMAL SET OF FUNCTIONAL
DEPENDENCIES
• A minimal set of functional dependencies is a set of
dependencies in standard form with no redundancies.
• Minimal cover of set of functional dependencies is the
minimal set of functional dependencies.
• Simple FD − X->Y is a simple FD if Y is a single attribute.
• Left reduced FD: X->Y is a left reduced FD if there are no
extraneous attributes in X.{extraneous attributes: let XA->Y
then A is a extraneous attribute if X_>Y}
• Non-redundant FD − X->Y is a Non-redundant FD if it
cannot be derived from F- {X->y}.
18
Problem
Find the canonical cover of FD {A->BC, B->AC, C->AB}.
Solution
Relational schema R(A,B,C) F: {A->BC, B->AC, C->AB}
Step 1 − Create a singleton right hand side
dependency A->BC will break into A->B, A->C.
19
Step 3 − Remove the redundant FD
F: { A->B A->C B->A B->C C->A C->B }
Remove B->A dependency and we can get A from B through B-
>C and C->A.
21
Exercise
ANSWER:
G = {A B, ACD E, EF G, EF H}.
22