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

Functional Dependency

- A functional dependency A->B holds if two tuples that have the same value for attribute A also have the same value for attribute B. - A functional dependency set specifies constraints on the legal relations for a relation schema based on which functional dependencies hold. - Attributes in the closure of an attribute set are functionally determined by that set based on the functional dependencies.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views

Functional Dependency

- A functional dependency A->B holds if two tuples that have the same value for attribute A also have the same value for attribute B. - A functional dependency set specifies constraints on the legal relations for a relation schema based on which functional dependencies hold. - Attributes in the closure of an attribute set are functionally determined by that set based on the functional dependencies.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 96

Functional Dependency &

Keys
Definition
• A functional dependency A->B in a relation holds if two tuples having same value of attribute
A also have same value for attribute B.
• Let R be a relation schema
  R and   R
• The functional dependency

holds on R if and only if for any legal relations r(R), whenever any two tuples t1 and t2 of r agree
on the attributes , they also agree on the attributes . That is,
t1[] = t2 []  t1[ ] = t2 [ ]
• Example: Consider r(A,B ) with the following instance of r.
1 4
1 5
3 7

• On this instance, A  B does NOT hold, but B  A does hold.


Q1. Among the followings, Which Functional Dependencies are correct on
the basis of given table?

A. STUD_NO -> STUD_NAME


B. STUD_NO -> STUD_PHONE
C. STUD_NAME -> STUD_STATE
Q1. Among the followings, Which Functional Dependencies are correct on
the basis of given table?

A. STUD_NO -> STUD_NAME


B. STUD_NO -> STUD_PHONE
C. STUD_NAME -> STUD_STATE
Q2. From the following instance of a relation scheme R (A, B, C), we can
conclude that :
A B C
1 1 1
1 1 0
2 3 2
2 3 2
A. A functionally determines B and B function¬ally determines C
B. A functionally determines B and B does not functionally determine C
C. B does not functionally determine C
D. A does not functionally determine B and B does not functionally
determine C
Q2. From the following instance of a relation scheme R (A, B, C), we can
conclude that :
A B C
1 1 1
1 1 0
2 3 2
2 3 2
A. A functionally determines B and B functionally determines C
B. A functionally determines B and B does not functionally determine C
C. B does not functionally determine C
D. A does not functionally determine B and B does not functionally
determine C
Q3. Given the following relation instance.
x y z
1 4 2
1 5 3
1 6 3
3 2 2
Which of the following functional dependencies are satisfied by the instance?
A. XY -> Z and Z -> Y
B. YZ -> X and Y -> Z
C. YZ -> X and X -> Z
D. XZ -> Y and Y -> X
Q3. Given the following relation instance.
x y z
1 4 2
1 5 3
1 6 3
3 2 2
Which of the following functional dependencies are satisfied by the instance?
A. XY -> Z and Z -> Y
B. YZ -> X and Y -> Z
C. YZ -> X and X -> Z
D. XZ -> Y and Y -> X
Use of Functional Dependencies

• We use functional dependencies to:


• test relations to see if they are legal under a given set of functional
dependencies.
• If a relation r is legal under a set F of functional dependencies,
we say that r satisfies F.
• specify constraints on the set of legal relations
• We say that F holds on R if all legal relations on R satisfy the set
of functional dependencies F.
Types of Functional Dependencies
• Trivial Functional Dependency
• Non Trivial Functional Dependency
• Semi Trivial Functional Dependency

• Trivial Functional Dependency 


X → Y is trivial only when Y is subset of X.
• Non Trivial Functional Dependencies 
X → Y is a non trivial functional dependency when Y is not a subset of X. 
X → Y is called completely non-trivial when X intersect Y is NULL.
• Semi Non Trivial Functional Dependencies 
X → Y is called semi non-trivial when X intersect Y is not NULL. 
• Trivial Functional Dependency
• Non Trivial Functional Dependency
• Semi Trivial Functional Dependency

• Trivial Functional Dependency 


X → Y is trivial only when _________________.
• Trivial Functional Dependency
• Non Trivial Functional Dependency
• Semi Trivial Functional Dependency

• Trivial Functional Dependency 


X → Y is trivial only when Y is subset of X.
• Trivial Functional Dependency
• Non Trivial Functional Dependency
• Semi Trivial Functional Dependency

• Trivial Functional Dependency 


X → Y is trivial only when Y is subset of X.
• Non Trivial Functional Dependencies 
X → Y is a non trivial functional dependency when___________. 
• Trivial Functional Dependency
• Non Trivial Functional Dependency
• Semi Trivial Functional Dependency

• Trivial Functional Dependency 


X → Y is trivial only when Y is subset of X.
• Non Trivial Functional Dependencies 
X → Y is a non trivial functional dependency when Y is not a subset of X. 
X → Y is called completely non-trivial when_____________. 
• Trivial Functional Dependency
• Non Trivial Functional Dependency
• Semi Trivial Functional Dependency

• Trivial Functional Dependency 


X → Y is trivial only when Y is subset of X.
• Non Trivial Functional Dependencies 
X → Y is a non trivial functional dependency when Y is not a subset of X. 
X → Y is called completely non-trivial when X intersect Y is NULL.
• Trivial Functional Dependency
• Non Trivial Functional Dependency
• Semi Trivial Functional Dependency

• Trivial Functional Dependency 


X → Y is trivial only when Y is subset of X.
• Non Trivial Functional Dependencies 
X → Y is a non trivial functional dependency when Y is not a subset of X. 
X → Y is called completely non-trivial when X intersect Y is NULL.
• Semi Non Trivial Functional Dependencies 
X → Y is called semi non-trivial when____________________. 
• Trivial Functional Dependency
• Non Trivial Functional Dependency
• Semi Trivial Functional Dependency

• Trivial Functional Dependency 


X → Y is trivial only when Y is subset of X.
• Non Trivial Functional Dependencies 
X → Y is a non trivial functional dependency when Y is not a subset of X. 
X → Y is called completely non-trivial when X intersect Y is NULL.
• Semi Non Trivial Functional Dependencies 
X → Y is called semi non-trivial when X intersect Y is not NULL. 
Example of Trivial, Non-Trivial and Semi
Non-Trivial Functional Dependencies
1. AB -> A
2. AB -> AD
3. AB -> AB
4. AB -> CD
Trivial Functional Dependencies –
Non-Trivial Functional Dependencies –
Semi Non-Trivial Functional Dependencies –
Example of Trivial, Non-Trivial and Semi
Non-Trivial Functional Dependencies
1. AB -> A
2. AB -> AD
3. AB -> AB
4. AB -> CD

Trivial Functional Dependencies – 1, 3


Non-Trivial Functional Dependencies – 4
Semi Non-Trivial Functional Dependencies – 2
Functional Dependency Set
Functional Dependency Set:  Functional Dependency set or FD set of a
relation is the set of all FDs present in the relation. For Example, FD set
for relation STUDENT shown in table 1 is:
{ STUD_NO->STUD_NAME,
STUD_NO->STUD_PHONE,
STUD_NO->STUD_STATE,
STUD_NO->STUD_COUNTRY,
STUD_NO -> STUD_AGE,
STUD_STATE->STUD_COUNTRY }
Closure of Attribute Sets
• Given a set of attributes a, define the closure of a under F (denoted by
a+) as the set of attributes that are functionally determined by a under F

• Algorithm to compute a+, the closure of a under F

result := a;
while (changes to result) do
for each    in F do
begin
if   result then result := result  
end
Q4.
FD1 = { STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE,
STUD_NO->STUD_STATE, STUD_NO->STUD_COUNTRY,
STUD_NO -> STUD_AGE, STUD_STATE->STUD_COUNTRY }
Using above functional dependency set FD1, find
{STUD_NO}+ = ?
Q4.
FD1 = { STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE,
STUD_NO->STUD_STATE, STUD_NO->STUD_COUNTRY,
STUD_NO -> STUD_AGE, STUD_STATE->STUD_COUNTRY }
Using above functional dependency set FD1, find
{STUD_NO}+ = {STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,
STUD_COUNTRY, STUD_AGE}
Q4.
FD1 = { STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE,
STUD_NO->STUD_STATE, STUD_NO->STUD_COUNTRY,
STUD_NO -> STUD_AGE, STUD_STATE->STUD_COUNTRY }
Using above functional dependency set FD1, find
{STUD_NO}+ = {STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,
STUD_COUNTRY, STUD_AGE}

{STUD_STATE}+ = ?
Q4.
FD1 = { STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE,
STUD_NO->STUD_STATE, STUD_NO->STUD_COUNTRY,
STUD_NO -> STUD_AGE, STUD_STATE->STUD_COUNTRY }
Using above functional dependency set FD1, find
{STUD_NO}+ = {STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,
STUD_COUNTRY, STUD_AGE}

{STUD_STATE}+ = {STUD_STATE, STUD_COUNTRY}


Q5. Let R = ABCDE is a relational scheme with functional dependency
set F = {A → B, B → C, AC → D}. The attribute closures of A and E are

A. ABCD, φ
B. ABCD, E
C. φ, φ
D. ABC, E
Q5. Let R = ABCDE is a relational scheme with functional dependency
set F = {A → B, B → C, AC → D}. The attribute closures of A and E are

A. ABCD, φ
B. ABCD, E
C. φ, φ
D. ABC, E
KEYS
• Super Key
• Candidate Key
• Primary Key
• Foreign Key
• Alternate Key
• Composite Key
Identifying Super Key and Candidate Key
using Functional Dependencies
• K is a super key for relation schema R if and only if K  R
• K is a candidate key for R if and only if
• K  R, and
• for no   K,   R

FD1 = { STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE,


STUD_NO->STUD_STATE, STUD_NO->STUD_COUNTRY,
STUD_NO -> STUD_AGE, STUD_STATE->STUD_COUNTRY }
Using above functional dependency set FD1, find

{STUD_NO, STUD_NAME}+ = ?
Identifying Super Key and Candidate Key
using Functional Dependencies
• K is a super key for relation schema R if and only if K  R
• K is a candidate key for R if and only if
• K  R, and
• for no   K,   R

FD1 = { STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE,


STUD_NO->STUD_STATE, STUD_NO->STUD_COUNTRY,
STUD_NO -> STUD_AGE, STUD_STATE->STUD_COUNTRY }
Using above functional dependency set FD1, find

{STUD_NO, STUD_NAME}+ = {STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,


STUD_COUNTRY, STUD_AGE} 
Identifying Super Key and Candidate Key
using Functional Dependencies
• K is a super key for relation schema R if and only if K  R
• K is a candidate key for R if and only if
• K  R, and
• for no   K,   R
FD1 = { STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE,
STUD_NO->STUD_STATE, STUD_NO->STUD_COUNTRY,
STUD_NO -> STUD_AGE, STUD_STATE->STUD_COUNTRY }
Using above functional dependency set FD1, find
{STUD_NO, STUD_NAME}+ = {STUD_NO, STUD_NAME, STUD_PHONE,
STUD_STATE, STUD_COUNTRY, STUD_AGE} 
{STUD_NO}+ = ?
Identifying Super Key and Candidate Key using
Functional Dependencies
• K is a super key for relation schema R if and only if K  R
• K is a candidate key for R if and only if
• K  R, and
• for no   K,   R
FD1 = { STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE,
STUD_NO->STUD_STATE, STUD_NO->STUD_COUNTRY,
STUD_NO -> STUD_AGE, STUD_STATE->STUD_COUNTRY }
Using above functional dependency set FD1, find
{STUD_NO, STUD_NAME}+ = {STUD_NO, STUD_NAME, STUD_PHONE,
STUD_STATE, STUD_COUNTRY, STUD_AGE} 
{STUD_NO}+ = {STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,
STUD_COUNTRY, STUD_AGE}
Identifying Super Key and Candidate Key
using Functional Dependencies
• K is a super key for relation schema R if and only if K  R
• K is a candidate key for R if and only if
• K  R, and
• for no   K,   R
{STUD_NO, STUD_NAME}+ = {STUD_NO, STUD_NAME, STUD_PHONE,
STUD_STATE, STUD_COUNTRY, STUD_AGE} 
{STUD_NO}+ = {STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,
STUD_COUNTRY, STUD_AGE}
Super Key = ?
Candidate Key = ?
Identifying Super Key and Candidate Key
using Functional Dependencies
• K is a super key for relation schema R if and only if K  R
• K is a candidate key for R if and only if
• K  R, and
• for no   K,   R
{STUD_NO, STUD_NAME}+ = {STUD_NO, STUD_NAME, STUD_PHONE,
STUD_STATE, STUD_COUNTRY, STUD_AGE} 
{STUD_NO}+ = {STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,
STUD_COUNTRY, STUD_AGE}
Super Key = {STUD_NO, STUD_NAME}
Candidate Key = ?
Identifying Super Key and Candidate Key
using Functional Dependencies
• K is a super key for relation schema R if and only if K  R
• K is a candidate key for R if and only if
• K  R, and
• for no   K,   R
{STUD_NO, STUD_NAME}+ = {STUD_NO, STUD_NAME, STUD_PHONE,
STUD_STATE, STUD_COUNTRY, STUD_AGE} 
{STUD_NO}+ = {STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,
STUD_COUNTRY, STUD_AGE}
Super Key = {STUD_NO, STUD_NAME}
Candidate Key = {STUD_NO}
Q6. Consider the relation scheme R = {E, F, G, H, I, J, K, L, M, N}
and the set of functional dependencies {{E, F} -> {G}, {F} -> {I, J},
{E, H} -> {K, L}, K -> {M}, L -> {N} on R. What is the candidate
key for R? (GATE-CS-2014) 
A. {E, F} 
B. {E, F, H} 
C. {E, F, H, K, L} 
D. {E} 
Q6. Consider the relation scheme R = {E, F, G, H, I, J, K, L, M, N}
and the set of functional dependencies {{E, F} -> {G}, {F} -> {I, J},
{E, H} -> {K, L}, K -> {M}, L -> {N} on R. What is the candidate
key for R? (GATE-CS-2014) 
A. {E, F} 
B. {E, F, H} 
C. {E, F, H, K, L} 
D. {E} 
Q6. Consider the relation scheme R = {E, F, G, H, I, J, K, L, M, N}
and the set of functional dependencies {{E, F} -> {G}, {F} -> {I, J}, {E,
H} -> {K, L}, K -> {M}, L -> {N} on R. What is the candidate key for
R? (GATE-CS-2014) 
A. {E, F} 
B. {E, F, H} 
C. {E, F, H, K, L} 
D. {E} 
Explanation
{E,F}+ = ?
{E,F,H}+ = ?
{E,F,H,K,L}+ = ?
{E}+ = ? 
Q6. Consider the relation scheme R = {E, F, G, H, I, J, K, L, M, N}
and the set of functional dependencies {{E, F} -> {G}, {F} -> {I, J}, {E,
H} -> {K, L}, K -> {M}, L -> {N} on R. What is the candidate key for
R? (GATE-CS-2014) 
A. {E, F} 
B. {E, F, H} 
C. {E, F, H, K, L} 
D. {E} 
Explanation
{E,F}+ = {EFGIJ} 
{E,F,H}+ = ?
{E,F,H,K,L}+ = ?
{E}+ = ? 
Q6. Consider the relation scheme R = {E, F, G, H, I, J, K, L, M, N}
and the set of functional dependencies {{E, F} -> {G}, {F} -> {I, J}, {E,
H} -> {K, L}, K -> {M}, L -> {N} on R. What is the candidate key for
R? (GATE-CS-2014) 
A. {E, F} 
B. {E, F, H} 
C. {E, F, H, K, L} 
D. {E} 
Explanation
{E,F}+ = {EFGIJ} 
{E,F,H}+ = {EFHGIJKLMN} 
{E,F,H,K,L}+ = ?
{E}+ = ? 
Q6. Consider the relation scheme R = {E, F, G, H, I, J, K, L, M, N}
and the set of functional dependencies {{E, F} -> {G}, {F} -> {I, J}, {E,
H} -> {K, L}, K -> {M}, L -> {N} on R. What is the candidate key for
R? (GATE-CS-2014) 
A. {E, F} 
B. {E, F, H} 
C. {E, F, H, K, L} 
D. {E} 
Explanation
{E,F}+ = {EFGIJ} 
{E,F,H}+ = {EFHGIJKLMN} 
{E,F,H,K,L}+ = {EFHGIJKLMN} 
{E}+ = ? 
Q6. Consider the relation scheme R = {E, F, G, H, I, J, K, L, M, N}
and the set of functional dependencies {{E, F} -> {G}, {F} -> {I, J}, {E,
H} -> {K, L}, K -> {M}, L -> {N} on R. What is the candidate key for
R? (GATE-CS-2014) 
A. {E, F} 
B. {E, F, H} 
C. {E, F, H, K, L} 
D. {E} 
Explanation
{E,F}+ = {EFGIJ} 
{E,F,H}+ = {EFHGIJKLMN} 
{E,F,H,K,L}+ = {EFHGIJKLMN} 
{E}+ = {E} 
Q7. Which of the following is NOT a superkey in a relational schema
with attributes V, W, X, Y, Z and primary key VY ?

A. V X Y Z
B. V W X Z
C. V W X Y
D. V W X Y Z
Q7. Which of the following is NOT a superkey in a relational schema
with attributes V, W, X, Y, Z and primary key VY ?

A. V X Y Z
B. V W X Z
C. V W X Y
D. V W X Y Z
Q8. Let R = ( A, B, C, D, E, F ) be a relation scheme with the following
dependencies: C→F, E→A, EC→D, A→B. Which of the following is a key
of R?

A. CD
B. EC
C. AE
D. AC
Q8. Let R = ( A, B, C, D, E, F ) be a relation scheme with the following
dependencies: C→F, E→A, EC→D, A→B. Which of the following is a key
of R?

A. CD
B. EC
C. AE
D. AC
Q9. Let x, y, z, a, b, c be the attributes of an entity set E. If {x}, {x,y},
{a,b}, {a,b,c}, {x,y,z} are superkeys then which of the following are the
candidate keys?

A. {x,y} and {a,b}


B. {x} and {a,b}
C. {x,y,z} and {a,b,c}
D. {z} and {c}
Q9. Let x, y, z, a, b, c be the attributes of an entity set E. If {x}, {x,y},
{a,b}, {a,b,c}, {x,y,z} are superkeys then which of the following are the
candidate keys?

A. {x,y} and {a,b}


B. {x} and {a,b}
C. {x,y,z} and {a,b,c}
D. {z} and {c}
Identifying whether an FD can be derived
from a given FD set?
• To check whether an FD A->B can be derived from an FD set F, 
 
1.Find (A)+ using FD set F.
2.If B is subset of (A)+, then A->B is true else not true.
Identifying whether an FD can be derived
from a given FD set?
To check whether an FD A->B can be derived from an FD set F, 
• Find (A)+ using FD set F.
• If B is subset of (A)+, then A->B is true else not true.
Q10. In a schema with attributes A, B, C, D and E following set of functional
dependencies are given {A -> B, A -> C, CD -> E, B -> D, E -> A} 
Which of the following functional dependencies is NOT implied by the above
set? (GATE IT 2005) 
A. CD -> AC 
B. BD -> CD 
C. BC -> CD 
D. AC -> BC
Identifying whether an FD can be derived
from a given FD set?
To check whether an FD A->B can be derived from an FD set F, 
• Find (A)+ using FD set F.
• If B is subset of (A)+, then A->B is true else not true.
Q10. In a schema with attributes A, B, C, D and E following set of functional
dependencies are given {A -> B, A -> C, CD -> E, B -> D, E -> A} 
Which of the following functional dependencies is NOT implied by the above
set? (GATE IT 2005) 
A. CD -> AC 
B. BD -> CD 
C. BC -> CD 
D. AC -> BC
Identifying whether an FD can be derived
from a given FD set?
To check whether an FD A->B can be derived from an FD set F, 
• Find (A)+ using FD set F.
• If B is subset of (A)+, then A->B is true else not true.
Q10. In a schema with attributes A, B, C, D and E following set of functional dependencies are given {A -
> B, A -> C, CD -> E, B -> D, E -> A} 
Which of the following functional dependencies is NOT implied by the above set? (GATE IT 2005) 
A. CD -> AC 
B. BD -> CD 
C. BC -> CD 
D. AC -> BC
Explanation
Using FD set given in question, 
(CD)+ = {CDEAB} which means CD -> AC also holds true. 
(BD)+ = {BD} which means BD -> CD can’t hold true. So this FD is no implied in FD set. So (B) is the
required option. 
Q11. Consider a relation scheme R = (A, B, C, D, E, H) on which the
following functional dependencies hold: {A–>B, BC–> D, E–>C, D–
>A}. What are the candidate keys of R? [GATE 2005] 
(a) AE, BE 
(b) AE, BE, DE 
(c) AEH, BEH, BCH 
(d) AEH, BEH, DEH 
Q11. Consider a relation scheme R = (A, B, C, D, E, H) on which the
following functional dependencies hold: {A–>B, BC–> D, E–>C, D–
>A}. What are the candidate keys of R? [GATE 2005] 
(a) AE, BE 
(b) AE, BE, DE 
(c) AEH, BEH, BCH 
(d) AEH, BEH, DEH 
Answer: (AE)+ = {ABECD} which is not set of all attributes. So AE is
not a candidate key. Hence option A and B are wrong. 
(AEH)+ = {ABCDEH} 
(BEH)+ = {BEHCDA} 
(BCH)+ = {BCHDA} which is not set of all attributes. So BCH is not a
candidate key. Hence option C is wrong. 
So correct answer is D.
Q12. Finding Candidate Keys and Super Keys of a Relation using
FD set F1 = {E-ID->E-NAME, E-ID->E-CITY, E-ID->E-STATE, E-
CITY->E-STATE} .
Q12. Finding Candidate Keys and Super Keys of a Relation using FD set F1 =
{E-ID->E-NAME, E-ID->E-CITY, E-ID->E-STATE, E-CITY->E-STATE} .
Ans.
Super Key = {(E-ID), (E-ID, E-NAME), (E-ID, E-CITY), (E-ID, E-STATE), (E-ID, E-
CITY, E-STATE)}

Candidate Key = ?
Q12. Finding Candidate Keys and Super Keys of a Relation using FD set F1 =
{E-ID->E-NAME, E-ID->E-CITY, E-ID->E-STATE, E-CITY->E-STATE} .
Ans.
Super Key = {(E-ID), (E-ID, E-NAME), (E-ID, E-CITY), (E-ID, E-STATE), (E-ID, E-
CITY, E-STATE)}

Candidate Key = E-ID


Q13. R = (A, B, C, G, H, I)
F = {A  B, A  C , CG  H, CG  I, B  H}. Is AG a candidate key?
Ans. ?
Q13. R = (A, B, C, G, H, I)
F = {A  B, A  C , CG  H, CG  I, B  H}. Is AG a candidate key?
Ans. Yes
Q13. R = (A, B, C, G, H, I)
F = {A  B, A  C , CG  H, CG  I, B  H}. Is AG a candidate key?
Ans. Yes
Explanation:
1. Is AG a super key?
1. Does AG  R? == Is (AG)+  R (AG)+ = ABCGHI
2. Is any subset of AG a superkey?
1. Does A  R? == Is (A)+  R
2. Does G  R? == Is (G)+  R
Prime and Non-Prime attributes
Attributes which are parts of any candidate key of relation are called as
prime attribute, others are non-prime attributes.
Example:
R = (A, B, C, D, E, H)
Candidate Keys – {AEH, BEH, DEH }
Prime Attributes – {A, B, D, E, H}
Non-Prime Attribute – {C}
Properties of Functional Dependency
Let X, Y, and Z are sets of attributes in a relation R. There are several properties of
functional dependencies which always hold in R also known as Armstrong Axioms.
1.Reflexivity: If Y is a subset of X, then X → Y. e.g.; Let X represents {E-ID, E-
NAME} and Y represents {E-ID}.  {E-ID, E-NAME}->E-ID is true for the relation.
2.Augmentation: If X → Y, then XZ → YZ. e.g.; Let X represents {E-ID}, Y represents
{E-NAME} and Z represents {E-CITY}. As {E-ID}->E-NAME is true for the
relation, so { E-ID,E-CITY}->{E-NAME,E-CITY} will also be true.
3.Transitivity: If X → Y and Y → Z, then X → Z. e.g.; Let X represents {E-ID}, Y
represents {E-CITY} and Z represents {E-STATE}. As {E-ID} ->{E-CITY} and {E-
CITY}->{E-STATE}  is true for the relation, so { E-ID }->{E-STATE} will also be
true.
4.Attribute Closure: The set of attributes that are functionally dependent on the
attribute A is called Attribute Closure of A and it can be represented as A +.
Number of Possible Super Keys in DBMS
Q14. Let a Relation R have attributes {a1,a2,a3} and a1 is the candidate
key. Then how many super keys are possible? 
Ans. ?
Number of Possible Super Keys in DBMS
Q14. Let a Relation R have attributes {a1,a2,a3} and a1 is the candidate
key. Then how many super keys are possible?
Ans. 4 
Number of Possible Super Keys in DBMS
Q15. Let a Relation R have attributes {a1,a2,a3} and a1 is the candidate
key. Then how many super keys are possible?
Ans. 4 
Explanation:
With the relation of Super Key and Candidate Key, any superset of
a1(Candidate Key) is the super key. 
Possible Superset of a1 = {a1, a1 a2, a1 a3, a1 a2 a3} 
So, Set of Super Keys = {a1, a1 a2, a1 a3, a1 a2 a3} 
Number of Possible Super Keys in DBMS
In general, if we have ‘N’ attributes in a relation and there is one
candidate key with ‘M’ attributes, then the number of possible super
keys are 2(N – M).

Q16. Let a Relation R have attributes {a1, a2, a3,…, an} and the
candidate key is “a1 a2 a3” then the possible number of super keys? 
Ans. ?
Number of Possible Super Keys in DBMS
In general, if we have ‘N’ attributes in a relation and there is one
candidate key with ‘M’ attributes, then the number of possible super
keys are 2(N – M).

Q16. Let a Relation R have attributes {a1, a2, a3,…, an} and the
candidate key is “a1 a2 a3” then the possible number of super keys? 
Ans. Possible Super Keys = 2(N-3)
Number of Possible Super Keys in DBMS
Q17. Let a Relation R have attributes {a1, a2, a3,…, an} and the
candidate keys are “a1”, “a2” then the possible number of super keys? 
Ans. ?
Number of Possible Super Keys in DBMS
Q17. Let a Relation R have attributes {a1, a2, a3,…, an} and the
candidate keys are “a1”, “a2” then the possible number of super keys? 
Ans. Possible Super Keys = (super keys possible with candidate key
A1) + (super keys possible with candidate key A2) – (common super
keys from both A1 and A2) 
Possible Super Keys = 2(n-1) + 2(n-1) - 2(n-2)

*Using Inclusion-Exclusion Principle


Number of Possible Super Keys in DBMS
Q18. Let a Relation R have attributes {a1, a2, a3,…, an} and the
candidate keys are “a1 a2”, “a3 a4” then the possible number of super
keys? 
Ans. ?
Number of Possible Super Keys in DBMS
Q18. Let a Relation R have attributes {a1, a2, a3,…, an} and the
candidate keys are “a1 a2”, “a3 a4” then the possible number of super
keys? 
Ans.
Possible Super Keys = Super keys of (a1 a2) + Super keys of (a3 a4) –
Super keys of(a1 a2 a3 a4)

Possible Super Keys = 2(n-2) + 2(n-2) - 2(n-4)


Number of Possible Super Keys in DBMS
Q19. Let a Relation R have attributes {a1, a2, a3,…, an} and the
candidate keys are “a1”, “a2 a3” then the possible number of super
keys? 
Ans. ?
Number of Possible Super Keys in DBMS
Q19. Let a Relation R have attributes {a1, a2, a3,…, an} and the
candidate keys are “a1”, “a2 a3” then the possible number of super
keys? 
Ans.
Possible Super Keys = Super keys of (a1) + Super keys of (a2 a3) –
Super keys of (a1 a2 a3) 
Possible Super Keys = 2(n-1) + 2(n-2) - 2(n-3)
Number of Possible Super Keys in DBMS
Q 20. Let a Relation R have attributes {a1, a2, a3,…,an} and the
candidate keys are “a1”, “a2”, “a3” then the possible number of super
keys? 
Ans. ?
Number of Possible Super Keys in DBMS
Q 20. Let a Relation R have attributes {a1, a2, a3,…,an} and the candidate
keys are “a1”, “a2”, “a3” then the possible number of super keys? 
Ans.
Possible Super Keys = (super keys possible with candidate key A1) + (super
keys possible with candidate key A2) + (super keys possible with candidate
key A3) – (common super keys from both A1 and A2) – (common super keys
from both A1 and A3) – (common super keys from both A2 and A3) +
(common super keys from A1, A2, and A3)
Possible Super Keys = 2(n-1) + 2(n-1) + 2(n-1) – 2(n-2) – 2(n-2) – 2(n-2) + 2(n-3)
Q21. The maximum number of superkeys for the relation schema
R(E,F,G,H) with E as the key is _____________.
Ans. ?
Q21. The maximum number of superkeys for the relation schema
R(E,F,G,H) with E as the key is _____________.
Ans. 8
Q22. Relation R has eight attributes ABCDEFGH. Fields of R contain only
atomic values. F = {CH -> G, A -> BC, B -> CFH, E -> A, F -> EG} is a set of
functional dependencies (FDs). How many candidate keys does the
relation R have?
Ans. ?
Q22. Relation R has eight attributes ABCDEFGH. Fields of R contain only
atomic values. F = {CH -> G, A -> BC, B -> CFH, E -> A, F -> EG} is a set of
functional dependencies (FDs). How many candidate keys does the
relation R have?
Ans. 4 - {A, B, E, F}
Q23. Relation R has eight attributes ABCDEFGH. Fields of R contain only
atomic values. F = {CH -> G, A -> BC, B -> CFH, E -> A, F -> EG} is a set of
functional dependencies (FDs) so that F+ is exactly the set of FDs that
hold for R. How many candidate keys does the relation R have?
Ans. ?
Closure of a Set of Functional
Dependencies
• Given a set F set of functional dependencies, there are certain other
functional dependencies that are logically implied by F.
• For e.g.: If A  B and B  C, then we can infer that A  C
• The set of all functional dependencies logically implied by F is the
closure of F.
• We denote the closure of F by F+.
Closure of a Set of Functional
Dependencies
• We can find F+, the closure of F, by repeatedly applying
Armstrong’s Axioms:
• if   , then    (reflexivity)
• if   , then      (augmentation)
• if   , and   , then    (transitivity)
• These rules are
• sound (generate only functional dependencies that actually hold), and
• complete (generate all functional dependencies that hold).
Example:
• R = (A, B, C, G, H, I)
F={ AB
AC
CG  H
CG  I
B  H}
• some members of F+
• AH
• by transitivity from A  B and B  H
• AG  I
• by augmenting A  C with G, to get AG  CG
and then transitivity with CG  I
• CG  HI
• by augmenting CG  I to infer CG  CGI,
and augmenting of CG  H to infer CGI  HI,
and then transitivity
Procedure for Computing F+
• To compute the closure of a set of functional dependencies F:
F+=F
repeat
for each functional dependency f in F+
apply reflexivity and augmentation rules on f
add the resulting functional dependencies to F +
for each pair of functional dependencies f1and f2 in F +
if f1 and f2 can be combined using transitivity
then add the resulting functional dependency to F +
until F + does not change any further
Alternative Procedure for Computing F+
• For each   R, we find the closure +, and for each S  +, we output a functional
dependency   S.
algorithm (F)
/* F is a set of FDs */
1. F + = ∅
2. for each possible attribute set X
3. compute the closure X + of X on F
4. for each attribute A ∈ X +
5. add to F + the FD: X → A
6. return F +
Example: Assume that there are 4 attributes A, B, C, D, and that F = {A →
B, B → C}. To compute F+.
Q23. Relation R has eight attributes ABCDEFGH. Fields of R contain only
atomic values. F = {CH -> G, A -> BC, B -> CFH, E -> A, F -> EG} is a set of
functional dependencies (FDs) so that F+ is exactly the set of FDs that
hold for R. How many candidate keys does the relation R have?
Ans. ?
Q23. Relation R has eight attributes ABCDEFGH. Fields of R contain only
atomic values. F = {CH -> G, A -> BC, B -> CFH, E -> A, F -> EG} is a set of
functional dependencies (FDs) so that F+ is exactly the set of FDs that
hold for R. How many candidate keys does the relation R have?
Ans. 4
Armstrong’s Axioms in Functional
Dependency
Axioms –
1. Axiom of reflexivity –
If A is a set of attributes and B is subset of A, then A holds B. If B is subset of A, then A ->
B}. This property is trivial property.
2. Axiom of augmentation –
If A -> B holds and Y is attribute set, then AY -> BY also holds. That is adding attributes in
dependencies, does not change the basic dependencies. If A -> B}, then AC -> BC for any C.
3. Axiom of transitivity –
Same as the transitive rule in algebra, if A ->B holds and B -> C holds, then A -> C also
holds. A -> B is called as A functionally that determines B. If X -> Y and Y -> Z} , then X -> Z.
Following rules can be derived from the Armstrong’s axioms.
1. Union –
If A -> B holds and A -> C holds, then A -> BC holds. If X -> Y and X -> Z then X -> YZ
2. Composition –
If A -> B and X -> Y holds, then AX -> BY holds.
3. Decomposition –
If A -> BC holds then A -> B and A -> C hold. If X -> YZ then X -> Y and X -> Z hold.
4. Pseudo Transitivity –
If A ->B holds and BC -> D holds, then AC -> D holds. If X -> Y and YZ -> W then XZ -
> W}.
Canonical Cover of Functional Dependencies
• Sets of functional dependencies may have redundant dependencies
that can be inferred from the others
• For example: A  C is redundant in: {A  B, B  C, A C}

• Intuitively, a canonical cover of F is a “minimal” set of functional


dependencies equivalent to F, having no redundant dependencies or
redundant parts of dependencies
Canonical Cover of Functional Dependencies
Extraneous attributes: An attribute of a functional dependency is said to be extraneous if we
can remove it without changing the closure of the set of functional dependencies.
•Consider a set F of functional dependencies and the functional dependency    in F.
•Attribute A is extraneous in  if A  
and F logically implies (F – {  })  {( – A)  }.
•Attribute A is extraneous in  if A  
and the set of functional dependencies
(F – {  })  { ( – A)} logically implies F.
•Note: implication in the opposite direction is trivial in each of the cases above, since a
“stronger” functional dependency always implies a weaker one
•Example: Given F = {A  C, AB  C }
•B is extraneous in AB  C because {A  C, AB  C} logically implies A  C (I.e. the result of
dropping B from AB  C).
•Example: Given F = {A  C, AB  CD}
•C is extraneous in AB  CD since AB  C can be inferred even after deleting C
Canonical Cover of Functional Dependencies
Consider a set F of functional dependencies and the functional
dependency    in F.
• To test if attribute A   is extraneous in 
1. compute ({} – A)+ using the dependencies in F
2. check that ({} – A)+ contains ; if it does, A is extraneous in 
• To test if attribute A   is extraneous in 
1. compute + using only the dependencies in
F’ = (F – {  })  { ( – A)},
2. check that + contains A; if it does, A is extraneous in 
Canonical Cover of Functional Dependencies
• A canonical cover for F is a set of dependencies Fc such that
• F logically implies all dependencies in Fc, and
• Fc logically implies all dependencies in F, and
• No functional dependency in Fc contains an extraneous attribute, and
• Each left side of functional dependency in Fc is unique.
• To compute a canonical cover for F:
repeat
Use the union rule to replace any dependencies in F
1  1 and 1  2 with 1  1 2
Find a functional dependency    with an
extraneous attribute either in  or in 
/* Note: test for extraneous attributes done using Fc, not F*/
If an extraneous attribute is found, delete it from   
until F does not change
Canonical Cover of Functional Dependencies
Q12. Consider the following set F of functional dependencies:
F= {A -> BC, B -> C, A -> B, AB -> C}. Find the Canonical Cover.
Ans. ?
Q12. Consider the following set F of functional dependencies:
F= {A -> BC, B -> C, A -> B, AB -> C}. Find the Canonical Cover.
Ans. Steps to find canonical cover:
1. There are two functional dependencies with the same set of attributes on the left: A -> BC, A -> B
These two can be combined to get A -> BC.
Now, the revised set F becomes: F= { A -> BC, B -> C, AB -> C }
2. There is an extraneous attribute in AB -> C because even after removing AB -> C from the set F,
we get the same closures. This is because B -> C is already a part of F.
Now, the revised set F becomes: F= {A -> BC, B -> C}
3. C is an extraneous attribute in A -> BC, also A -> B is logically implied by A -> B and B -> C (by
transitivity).
F= {A -> B, B -> C}
After this step, F does not change anymore. So,
Hence the required canonical cover is: F= {A -> B, B -> C}

You might also like