0% found this document useful (0 votes)
32 views22 pages

DBMS

The document discusses attribute closure and finding candidate keys of relations from given functional dependencies. It provides examples of finding closure of attributes and determining if a set of attributes is a candidate key. It also includes some GATE questions related to functional dependencies and candidate keys.

Uploaded by

rashiiiiic
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)
32 views22 pages

DBMS

The document discusses attribute closure and finding candidate keys of relations from given functional dependencies. It provides examples of finding closure of attributes and determining if a set of attributes is a candidate key. It also includes some GATE questions related to functional dependencies and candidate keys.

Uploaded by

rashiiiiic
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/ 22

UNIT 2

Lecture 30
Normalization
Attribute Closure
Closure of a set of FDs (Attribute Closure)
1. The closure of a set of FDs is the set of all FDs implied by a given set
of FDs.
2. It can be calculated using Armstrong Axioms.
3. It can be used to check if a FD follows from a given set.
4. Can check if a set of attributes is a candidate key.

Dinesh Kumar Bhawnani, BIT DURG


Armstrong Axiom to find Closure
X+ :=X;
Repeat
Old X+ :=X+ ;
For each functional dependency Y  Z in F do
If X+ ‫ כ‬Y then X+ := X+ U Z;
Until (X+ = Old X+);

Dinesh Kumar Bhawnani, BIT DURG


Q.1 Suppose we are given a relation schema R = (A, B, C, G, H, I) and the set
of FDs. A  B, A  C, CG  H, CG  I, B  H. Find (AG)+.
Sol : Given relation R (A, B, C, G, H, I) and set of functional dependencies are
A  B, A  C, CG  H, CG  I, B  H, so to find (AG)+.
Iteration Using Result (AG)+ Old (AG)+
1 AG AG
2 AB ABG AG
3 AC ABCG AG
4 CG  H ABCGH AG
5 CG  I ABCGHI AG
6 BH ABCGHI AG
7 ABCGHI ABCGHI

So (AG)+ = ABCGHI.
Since (AG)+ contains all the attributes of relation R so AG is the key of R.
Dinesh Kumar Bhawnani, BIT DURG
Q.2 What is closure of attributes, give the algorithm for it with given relation R
(A, B, C, D, E, F) and following set of functional dependencies.
A  BC, E  CF, B  E, CD  EF
(i) Computer (AB)+.
(ii) Is AC  CF implied by above FD’s?
Sol : Given relation R (A, B, C, D, E, F) and set of functional dependencies are
A  BC, E  CF, B  E, CD  EF, so to find (AB)+.
Iteration Using Result (AB)+ Old (AB)+
1 AB AB
2 A  BC ABC AB
3 BE ABCE AB
4 E  CF ABCEF AB
5 ABCEF ABCEF

So (AB)+ = ABCEF.
Dinesh Kumar Bhawnani, BIT DURG
Q.2 What is closure of attributes, give the algorithm for it with given relation R
(A, B, C, D, E, F) and following set of functional dependencies.
A  BC, E  CF, B  E, CD  EF
(i) Computer (AB)+.
(ii) Is AC  CF implied by above FD’s?
Sol : Now to check whether AC  CF is implied by FDs we need to find (AC)+.
Iteration Using Result (AC)+ Old (AC)+
1 AC AC
2 A  BC ABC AC
3 BE ABCE AC
4 E  CF ABCEF AC
5 ABCEF ABCEF

So (AC)+ = ABCEF. Since (AC)+ contains CF, so we can say AC  CF.

Dinesh Kumar Bhawnani, BIT DURG


Q.3 Consider a relation R (A, B, C, D, E) with the following functional dependencies
AB  C, CD E, DE  B.
Is AB a candidate key of this relation? If not, is ABD? Explain your answer.
Sol : For AB to be a candidate key of this relation it can determine all the attributes of
this relation that is for AB to be a candidate key if and if only if AB  ABCDE, so we
need to find (AB)+.
Iteration Using Result (AB)+ Old (AB)+
1 AB AB
2 AB  C ABC AB
3 ABC ABC

So (AB)+ = ABC. Since (AB)+ do not contain all the attribute of this relation, AB is not a
candidate key of this relation.

Dinesh Kumar Bhawnani, BIT DURG


Q.3 Consider a relation R (A, B, C, D, E) with the following functional dependencies
AB  C, CD E, DE  B.
Is AB a candidate key of this relation? If not, is ABD? Explain your answer.
Sol : For ABD to be a candidate key of this relation it can determine all the attributes
of this relation that is for ABD to be a candidate key if and if only if ABD  ABCDE, so
we need to find (ABD)+.
Iteration Using Result (ABD)+ Old (ABD)+
1 ABD ABD
2 AB  C ABCD ABD
3 CD  E ABCDE ABCD
4 DE  B ABCDE ABCD
5 ABCDE ABCDE

So (ABD)+ = ABCDE. Since (ABD)+ contains all the attribute of this relation, ABD is a
candidate key of this relation.
Dinesh Kumar Bhawnani, BIT DURG
Q.4 Let the relation :
R = {A, B, C, D, E, F, G} satisfies following FD’s
Let F = {A  B, BC  DE, AEF  G, B  F}
Find A+, BC+, AEF+.
Q.5 Let the relation
R (A, B, C, D, E, F, G)
Satisfies the following FD’s
A  B,
BC  DE,
AEF  G
Compute the closure {A, C}+.
Is the FD ACF  DG implied by this set.

Dinesh Kumar Bhawnani, BIT DURG


GATE Question
The following functional dependencies are given :
AB CD, AF D, DE  F, C  G, F  E, G A
Which one of the following option is false?
(A) {CF}+ = {ACDEFG}
(B) {BG}+= {ABCDG}
(C) {AF}+ = {ACDEFG}
(D) {AB}+= {ABCDFG}
[GATE 2006]

Dinesh Kumar Bhawnani, BIT DURG


GATE Question
In a scheme with attribute 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?
(a) CD → AC (b) BD → CD
(c) BC → CD (d) AC → BC
[GATE 2005]

Dinesh Kumar Bhawnani, BIT DURG


GATE Question
Prime Attribute – An attribute of relation schema R is called a prime
attribute of R if it is a member of some candidate key of R.
Nonprime Attribute – An attribute is called nonprime if it is not a prime
attribute, i.e. if it is not a member of any candidate key.

A prime attribute of a relation scheme R is an attribute that appears


(A) in all candidate keys of R.
(B) in some candidate key of R.
(C) in a foreign keys of R.
(D) only in the primary key of R.
[GATE 2014]
Dinesh Kumar Bhawnani, BIT DURG
Finding candidate key of Relation
Q.1 Consider a relation R (A, B, C, D, E) with a set of FDs
F = {A  BC, C  D, D  E}.
Find candidate key of R.
Sol : Super key of this relation is = ABCDE
Essential attribute for candidate key = A
Find A+ = ABCDE
Since A contains all the attributes of this relation, A is an candidate key of this
relation.
So prime attribute is = A
Non prime attributes are = B, C, D, E

Dinesh Kumar Bhawnani, BIT DURG


Finding candidate key of Relation
Q.2 Consider a relation R (A, B, C, D, E) with a set of FDs
F = {AB  C, C  D, D  E, E  B}.
Find candidate key of R.
Sol : Super key of this relation is = ABCDE
Essential attribute for candidate key = A
Find A+ = A
Since A do not contain all the attributes of this relation, A is not an candidate key of this
relation. That means relation R has multiple candidate keys and every candidate key must
contain attribute A. So we try all the combinations of A.
So, AB+ = ABCDE, implies that AB is an candidate key.
AC+ = ABCDE, implies that AC is an candidate key.
AD+ = ABCDE, implies that AD is an candidate key.
AE+ = ABCDE, implies that AE is an candidate key.
So we have 4 candidate keys.
Prime attributes are = A, B, C, D, E
Non prime attributes are = ø
Dinesh Kumar Bhawnani, BIT DURG
Finding candidate key of Relation
Q.3 Consider a relation R (A, B, C, D, E) with a set of FDs
F = {A  BC, CD  E, B  D, E  A}.
Find candidate key of R.
Sol : Super key of this relation is = ABCDE
Essential attribute for candidate key = ø
That means relation R has multiple candidate keys and no attribute is common in any candidate key. So we
need to find the closure of all the determinants.
So, A+ = ABCDE, implies that A is an candidate key.
CD+ = ABCDE, implies that CD is an candidate key.
B+ = BD, implies that B is not an candidate key.
E+ = ABCDE, implies that E is an candidate key.
So we try the combination of B with C and D and check whether BC or CD is an candidate key.
So, BC+ = ABCDE
BD+ = BD
So, the candidate keys of this relation are A, BC, CD, E.
Prime attributes are = A, B, C, D, E
Non prime attributes are = ø

Dinesh Kumar Bhawnani, BIT DURG


GATE Question
Consider the relation schema 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 key for R?
(a) {E, F}
(b) {E, F, H}
(c) {E, F, H, K, L}
(d) {E}
[GATE 2014]

Dinesh Kumar Bhawnani, BIT DURG


GATE Question
Which of the following is NOT a super key in a relational schema with
attributes V, W, X, Y, Z and primary key VY?
(A) VXYZ
(B) VWXZ
(C) VWXY
(D) VWXYZ
[GATE 2016]

Dinesh Kumar Bhawnani, BIT DURG


GATE Question
The maximum number of super keys for the relation
schema R (E, F, G, H) with E as the key is ___.
[GATE 2014]

Dinesh Kumar Bhawnani, BIT DURG


GATE Question
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.
Q. How many candidate keys does the relation R have?
(A) 3
(B) 4
(C) 5
(D) 6
[GATE 2013]

Dinesh Kumar Bhawnani, BIT DURG


GATE Question
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}. Which
are the candidate keys of R?
(A) AE, BE
(B) AE, BE, DE
(C) AEH, BEH, BCH
(D) AEH, BEH, DEH
[GATE 2005]

Dinesh Kumar Bhawnani, BIT DURG


GATE Question
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 the
key for R?
(A) CD
(B) EC
(C) AE
(D) AC
[GATE 1999]

Dinesh Kumar Bhawnani, BIT DURG


For Video lecture on this topic please subscribe to my youtube channel.

The link for my youtube channel is

https://www.youtube.com/channel/UCRWGtE76JlTp1iim6aOTRuw?sub
_confirmation=1

Dinesh Kumar Bhawnani, BIT DURG

You might also like