Workbookdocx (1) PDF
Workbookdocx (1) PDF
A relation is in third normal form, if there is no transitive dependency for non-prime attributes
as well as it is in second normal form.
A relation is in 3NF if at least one of the following condition holds in every non-trivial
function dependency X –> Y
1. X is a super key.
Y is a prime attribute (each element of Y is part of some candidate key). Transitive
dependency
If A->B and B->C are two FDs then A->C is called transitive dependency.
101 Akon OS
101 Akon CN
102 Bkon C
Closure of attribute A-
D+ = {D }
= { D ,F } ( Using A → BC )
={A,B,C,D,E} ( Using BC → DE )
={A,B,C,D,E,F} ( Using D → F )
={A,B,C,D,E,F,G} ( Using CF → G )
Thus,
A+ = { A , B , C , D , E , F , G }
Closure of attribute D-
D+ = { D }
= { D , F } ( Using D → F )
We can not determine any other attribute using attributes D and F contained in the result set.
Thus,
D+ = { D , F }
{ B , C }+= { B , C }
={B,C,D,E} ( Using BC → DE )
={B,C,D,E,F} ( Using D → F )
={B,C,D,E,F,G} ( Using CF → G )
Thus,
{ B , C }+ = { B , C , D , E , F , G }
Step-02:
The remaining attributes of the relation are non-essential attributes. This is because they can be determined by
using essential attributes.
Now, following two cases are possible-
Case-01:
If all essential attributes together can determine all remaining non-essential attributes, then-
● The combination of essential attributes is the candidate key.
● It is the only possible candidate key.
Case-02:
If all essential attributes together cannot determine all remaining non-essential attributes, then-
● The set of essential attributes and some non-essential attributes will be the candidate key(s).
● In this case, multiple candidate keys are possible.
● To find the candidate keys, we check different combinations of essential and non-essential attributes.
Problem-01:
Let R = (A, B, C, D, E, F) be a relation scheme with the following dependencies-
C→F
E→A
EC → D
A→B
Essentails attributes {C E} +={ C ,E, F, A,B,D}
Which of the following is a key for R?
1. CD
2. EC
3. AE
4. AC
Step-01:
Determine all essential attributes of the given relation.
Essential attributes of the relation are- C and E.
So, attributes C and E will definitely be a part of every candidate key.
Step-02:
Now,
● We will check if the essential attributes together can determine all remaining non-essential attributes.
● To check, we find the closure of CE.
● So, we have-
● { CE }+
● ={C,E}
● ={C,E,F} ( Using C → F )
● ={A,C,E,F} ( Using E → A )
● ={A,C,D,E,F} ( Using EC → D )
● ={A,B,C,D,E,F} ( Using A → B )
●
● We conclude that CE can determine all the attributes of the given relation.
● So, CE is the only possible candidate key of the relation.
Problem-02:
Let R = (A, B, C, D, E) be a relation scheme with the following dependencies-
AB → C
C→D
B→E
Determine the total number of candidate keys
So, we have-
{ AB }+
={A,B}
={A,B,C} ( Using AB → C )
={A,B,C,D} ( Using C → D )
={A,B,C,D,E} ( Using B → E )
We conclude that AB can determine all the attributes of the given relation.
Thus, AB is the only possible candidate key of the relation.
Only one candidate key AB is possible.
Problem 03
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}
{E F H }+
We conclude that EFH can determine all the attributes of the given relation.
7. Given a schema R( A, B, C, D, E), and the following set of FDs: {A→ E, E → CD,
BC → A, D → B}
LHS Due to the FDs Result becomes Description
A+ A→ E = AE (Reflexive) The result of A+ is
E→ CD = AECD (Transitive) equivalent to R.
D→ B = AECDB (Transitive) A is a candidate key.
= ABCDE
E+ E→ CD = ECD (Reflexive) E+ gives R.
D→ B = ECDB (Transitive) E is a candidate key.
BC→ A = ECDBA (Transitive)
= ABCDE
D+ = DB D→ B (Reflexive) D+ is not equivalent to
R.
D is not a candidate
key.
B+ or Neither B nor C alone form the LHS of any FDs. Hence, they
C+ individually cannot form a candidate key.
So far we have tried individual (singleton) attributes. We can now try the
combination of different attributes. We do not need to test the combination
of attributes that have either A or E. The superset of either A or E cannot be
a candidate key.
(BC)+ BC→ A = BCA (Reflexive) (BC)+ is equivalent to
A→ E = BCAE (Transitive) R.
E→ CD = BCAED (Transitive) (BC) is a candidate key.
= ABCDE
(CD)+ D→ B = CDB (Reflexive) (CD) is a candidate
BC→ A = CDBA (Augment) key.
A→ E = CDBAE (Transitive)
= ABCDE
A, E, BC, and CD are the candidate keys of the relation R.
Problem- 1
A relation R (A , C , D , E , H) is having two functional dependencies sets F and G as shown-Find whether
they are equivalent
F- {A → C, AC → D, E → AD,E → H}
G- { A → CD, E → AH}
F COVERS G G COVERS F
A+= {A CD} A+ ={ A C D}
E+= { E A H CD} AC+={AC D}
E+={ E AC D H}
Determining whether F covers G-
● (A)+ = { A , C , D } // closure of left side of A → CD using set F
● (E)+ = { A , C , D , E , H } // closure of left side of E → AH using set F
Problem 2
a) P is a subset of Q
b) Q is a subset of P
c) P = Q
d) P ≠ Q
→Using definition of equivalence of FD set, let us determine the right-hand side of the FD set of P using FD set
Q.
Now compare closure of each A, B and C calculated using FD Q with the right-hand side of FD P. Closure B is
B while in FD set P, B → C (B determines C), since the closure of B determined using FD Q has no C. Hence,
we can say P is not a subset of Q----------1
→Using definition of equivalence of FD set, let us determine the right-hand side of the FD set of Q using FD
set P.
a. A+ = ABCD (using A → B, B → C, C → D)
b. C+ = CD (using C → D)
Now compare closure of each A and C calculated using FD P with the right-hand side of FD Q. Closure of each
A and C has all the attributes which are on the right-hand side of each FD of Q. Hence, we can say Q is a
subset of P-----------2
From 1 and 2 we can say that only Q is a subset of P since from 1 condition violated, hence option B is
correct ie Q is a subset of P
Problem 3
a. P is a subset of Q
b. Q is a subset of P
c. P = Q
d. P ≠ Q
→Using definition of equivalence of FD set, let us determine the right-hand side of the FD set of P using FD set
Q.
Now compare closure of each X, Y, Z calculated using FD Q with the right-hand side of FD P. Closure of each
X, Y, Z has all the attributes which are on the right-hand side of each FD of P. Hence, we can say P is a subset
of Q----------1
→Using definition of equivalence of FD set, let us determine the right-hand side of the FD set of Q using FD
set P.
a. X+ = XYZ (using X → Y, Y → Z, Z → X)
b. Y+ = YZX (using Y → Z, Z → X)
c. Z+ = ZXY (using X → Y, Y → Z, Z → X)
Now compare closure of each X, Y and Z calculated using FD P with the right-hand side of FD Q. Closure of
each X, Y and Z has all the attributes which are on the right-hand side of each FD of Q. Hence, we can say Q is
a subset of P-----------2
1. From 1 and 2 we can say that P = Q, option C is correct. P = Q
Problem 4
Suppose, a relational schema R (v w x y z) and set of functional dependencies F and G are as follow: F : { w→
y, z→ wy, z→ v } G :{ w→ xy, z→ wx} Check the equivalency of functional dependencies F and G.
x, wx →
Problem 5
Suppose, a relational schema R (P,Q, R, S) and set of functional dependencies F and G are as follow:
Problem 1
The following functional dependencies hold true for the relational scheme R ( W , X , Y , Z ) –
X→W
WZ → XY
Y → WXZ
Write the irreducible equivalent for this set of functional dependencies.
Solution-
Step-01:
Write all the functional dependencies such that each contains exactly one attribute on its right side-
X→W
WZ → X
WZ → Y
Y→W
Y→X
Y→Z
Step-02:
Check the essentiality of each functional dependency one by one.
For X → W:
Considering X → W, (X)+ = { X , W }
● Ignoring X → W, (X)+ = { X }
Now,
● Clearly, the two results are different.
● Thus, we conclude that X → W is essential and cannot be eliminated.
For WZ → X:
Considering WZ → X, (WZ)+ = { W , X , Y , Z }
● Ignoring WZ → X, (WZ)+ = { W , X , Y , Z }
Now,
● Clearly, the two results are same.
● Thus, we conclude that WZ → X is non-essential and can be eliminated.
Now,
● Clearly, the two results are different.
● Thus, we conclude that WZ → Y is essential and cannot be eliminated.
For Y → W:
Considering Y → W, (Y)+ = { W , X , Y , Z }
● Ignoring Y → W, (Y)+ = { W , X , Y , Z }
Now,
● Clearly, the two results are same.
● Thus, we conclude that Y → W is non-essential and can be eliminated.
Eliminating Y → W, our set of functional dependencies reduces to-
X→W
WZ → Y
Y→X
Y→Z
For Y → X:
Considering Y → X, (Y)+ = { W , X , Y , Z }
● Ignoring Y → X, (Y)+ = { Y , Z }
Now,
● Clearly, the two results are different.
● Thus, we conclude that Y → X is essential and can not be eliminated.
For Y → Z:
● Considering Y → Z, (Y)+ = { W , X , Y , Z }
● Ignoring Y → Z, (Y)+ = { W , X , Y }
Now,
● Clearly, the two results are different.
● Thus, we conclude that Y → Z is essential and can not be eliminated.
From here, our essential functional dependencies are-
X→W
WZ → Y
Y→X
Y→Z
Step-03:
Consider the functional dependencies having more than one attribute on their left side.
Check if their left side can be reduced.
In our set,
● Only WZ → Y contains more than one attribute on its left side.
● Considering WZ → Y, (WZ)+ = { W , X , Y , Z }
Now,
● Consider all the possible subsets of WZ.
● Check if the closure result of any subset matches to the closure result of WZ.
(W)+ = { W }
(Z)+ = { Z }
Clearly,
● None of the subsets have the same closure result same as that of the entire left side.
● Thus, we conclude that we can not write WZ → Y as W → Y or Z → Y.
● Thus, set of functional dependencies obtained in step-02 is the canonical cover.
Finally, the canonical cover is-
Ans X → W, WZ → Y, Y → X, Y → Z
Problem 2
Find Minimal Cover for the following
F = {A → C, AB → C, C → DI, CD → I, EC → AB, EI → C}
1. Right Hand Side (RHS) of all FDs should be single attribute. So we write F as F1, as follows;
Problem 3
Consider the following set F of functional dependencies:
F= { A - > BC B -> C A -> B AB -> C }
Ans F= { A -> B B -> C }
Problem 4
F = { AB -> C, C -> A, BC -> D, ACD -> B, D -> E, D - > G, BE -> C, CG -> B, CG -> D, CE -> A, CE -> G}
Problem 5
Find the canonical cover of F = { A -> BC, B-> CE, A -> E, AC-> H, D -> B}
Ans: Fc= { A -> BH, B-> CE, D-> B}
Problem 6
F = {A->BC, B ->CE, A ->E }
Ans F = { A ->B, B-> CE}
Problem 4
F = { AB -> C, C -> A, BC -> D, ACD -> B, D -> E, D - > G, BE -> C, CG -> B, CG -> D, CE -> A, CE -> G}