DBMS
DBMS
= {A, B, C, D, E}.
A -> BC
CD -> E
B -> D
E -> A
List the candidate keys for R.
Answer:
A -> BC, B -> D so A -> D so A -> DC -> E
therefore A -> ABCDE
Attribute closure:
A -> ABCDE
B -> BD
C -> C
D -> D
E -> ABCDE
AB -> ABCDE
AC -> ABCDE
AD -> ABCDE
AE -> ABCDE
BC -> ABCDE
BD -> BD
BE -> ABCDE
CD -> ABCDE
CE -> ABCDE
DE -> ABCDE
ABC -> ABCDE
ABD -> ABCDE
ABE -> ABCDE
ACD -> ABCDE
ACE -> ABCDE
ADE -> ABCDE
BCD -> ABCDE
BDE -> ABCDE
CDE -> ABCDE
ABCD -> ABCDE
ABCE -> ABCDE
ABDE -> ABCDE
ACDE -> ABCDE
BCDE -> ABCDE
Solution: Let us construct an arrow diagram on R using FD to calculate the candidate key.
From above arrow diagram on R, we can see that an attributes AB is not determined by any of the given FD,
hence AB will be the integral part of the Candidate key, i.e. no matter what will be the candidate key, and how
many will be the candidate key, but all will have W compulsory attribute.
Since the closure of AB contains all the attributes of R, hence AB is Candidate Key
From the definition of Candidate Key(Candidate Key is a Super Key whose no proper subset is a Super key)
Since all key will have AB as an integral part, and we have proved that AB is Candidate Key, Therefore, any
superset of AB will be Super Key but not Candidate key.
Since R has 4 attributes: - A, B, C, D, and Candidate Key is AB, Therefore, prime attributes (part of candidate
key) are A and B while a non-prime attribute are C and D
a) FD: AB → CD satisfies the definition of 2NF, that non-prime attribute(C and D) are fully dependent on
candidate key AB
b) FD: B → C does not satisfy the definition of 2NF, as a non-prime attribute(C) is partially dependent on
candidate key AB( i.e. key should not be broken at any cost)
Since FD: B → C, our table was not in 2NF, let's decompose the table
R1(B, C)
Since the key is AB, and from FD AB → CD, we can create R2(A, B, C, D) but this will again have a problem
of partial dependency B → C, hence R2(A, B, D).
b) R2(A, B, D)
Solution: Let us construct an arrow diagram on R using FD to calculate the candidate key.
From above arrow diagram on R, we can see that an attributes PQS is not determined by any of the given FD,
hence PQS will be the integral part of the Candidate key, i.e., no matter what will be the candidate key, and how
many will be the candidate key, but all will have PQS compulsory attribute.
Since the closure of PQS contains all the attributes of R, hence PQS is Candidate Key
From the definition of Candidate Key (Candidate Key is a Super Key whose no proper subset is a Super
key)
Since all key will have PQS as an integral part, and we have proved that PQS is Candidate Key. Therefore, any
superset of PQS will be Super Key but not Candidate key.
Since R has 5 attributes: - P, Q, R, S, T and Candidate Key is PQS, Therefore, prime attributes (part of candidate
key) are P, Q, and S while a non-prime attribute is R and T
a) FD: PQ → R does not satisfy the definition of 2NF, that non-prime attribute( R) is partially dependent on part
of candidate key PQS.
b) FD: S → T does not satisfy the definition of 2NF, as a non-prime attribute(T) is partially dependent on
candidate key PQS (i.e., key should not be broken at any cost).
Since due to FD: PQ → R and S → T, our table was not in 2NF, let's decompose the table
R1(P, Q, R) (Now in table R1 FD: PQ → R is Full F D, hence R1 is in 2NF)
And create one table for the key, since the key is PQS.
R3(P, Q, S)
a) R1( P, Q, R)
b) R2(S, T)
c) R3(P, Q, S)
Solution: Let us construct an arrow diagram on R using FD to calculate the candidate key.
From above arrow diagram on R, we can see that an attributes XZ is not determined by any of the given FD,
hence XZ will be the integral part of the Candidate key, i.e. no matter what will be the candidate key, and how
many will be the candidate key, but all will have XZ compulsory attribute.
Since the closure of XZ contains all the attributes of R, hence XZ is Candidate Key
From the definition of Candidate Key (Candidate Key is a Super Key whose no proper subset is a Super
key).
Since all key will have XZ as an integral part, and we have proved that XZ is Candidate Key, Therefore, any
superset of XZ will be Super Key but not the Candidate key.
Definition of 3NF: First it should be in 2NF and if there exists a non-trivial dependency between two sets of
attributes X and Y such that X → Y ( i.e., Y is not a subset of X) then
Since R has 5 attributes: - X, Y, Z, W, P and Candidate Key is XZ, Therefore, prime attribute (part of candidate
key) are X and Z while a non-prime attribute are Y, W, and P
a. FD: X → Y does not satisfy the definition of 3NF, that neither X is Super Key nor Y is a prime
attribute.
b. FD: Y → P does not satisfy the definition of 3NF, that neither Y is Super Key nor P is a prime attribute.
c. FD: Z → W satisfies the definition of 3NF, that neither Z is Super Key nor W is a prime attribute.
Since all the FD = { X → Y, Y → P, and Z → W} were not in 3NF, let us convert R in 3NF
R1(X, Y) {Using FD X → Y}
R2(Y, P) {Using FD Y → P}
R3(Z, W) {Using FD Z → W}
All the decomposed tables R1, R2, R3, and R4 are in 2NF( as there is no partial dependency) as well as in 3NF.
Solution: Let us construct an arrow diagram on R using FD to calculate the candidate key.
From above arrow diagram on R, we can see that an attribute PQ is not determined by any of the given FD,
hence PQ will be the integral part of the Candidate key, i.e. no matter what will be the candidate key, and how
many will be the candidate key, but all will have PQ compulsory attribute.
Since the closure of XZ contains all the attributes of R, hence PQ is Candidate Key
From the definition of Candidate Key (Candidate Key is a Super Key whose no proper subset is a Super
key)
Since all key will have PQ as an integral part, and we have proved that XZ is Candidate Key, Therefore, any
superset of PQ will be Super Key but not Candidate key.
Definition of 3NF: First it should be in 2NF and if there exists a non-trivial dependency between two sets of
attributes X and Y such that X → Y (i.e., Y is not a subset of X) then
d) Or Y is a prime attribute.
Given FD are {PQ → R, P → ST, Q → U, U → VW and S → XY} and Super Key / Candidate Key is PQ
Since all the FD = { P → ST, Q → U, U → VW, and S → XY } were not in 3NF, let us convert R in 3NF
R1(P, S, T) {Using FD P → ST }
R2(Q, U) {Using FD Q → U }
R3( U, V, W) { Using FD U → VW }
R4( S, X, Y) { Using FD S → XY }
All the decomposed tables R1, R2, R3, R4, and R5 are in 2NF( as there is no partial dependency) as well as in
3NF.
Hence decomposed tables are:
R1(P, S, T), R2(Q, U), R3(U, V, W), R4( S, X, Y), and R5( P, Q, R)
Conclusion: From the above three examples, we can conclude that the following steps are followed to check
whether the given relational schema R is in 3 NF or not? If not, how to decompose it into 3 NF.
STEP 1: Calculate the Candidate Key of given R by using an arrow diagram and then using the closure of an
attribute on R, such that from the calculated candidate key, we can separate the prime attributes and non-prime
attributes.
STEP 2: Verify each FD with Definition of 3NF (First it should be in 2NF and if there exist a non-trivial
dependency between two sets of attributes X and Y such that X → Y (i.e., Y is not a subset of X) then Either X
is Super Key or Y is a prime attribute).
STEP 3: Make a set of FD which does not satisfy 3NF, i.e. all those FD which do not have an attribute on the
left side of FD as a super key or attribute on the right side of FD as a prime attribute.
STEP 4: Convert the table R in 3NF by decomposing R such that each decomposition based on FD should
satisfy the definition of 3NF.
STEP 5: Once the decomposition based on FD is completed, create a separate table of attributes in the Candidate
key.
STEP 6: All the decomposed R obtained from STEP 4 and STEP 5 forms the required decomposition where
each decomposition is in 3NF.
Solution: Let us construct an arrow diagram on R using FD to calculate the candidate key.
From the above arrow diagram on R, we can see that an attribute PQS is not determined by any of the given FD,
hence PQS will be the integral part of the Candidate key, i.e. no matter what will be the candidate key, and how
many will be the candidate key, but all will have PQS compulsory attribute.
Since the closure of PQS contains all the attributes of R, hence PQS is Candidate Key
From the definition of Candidate Key (Candidate Key is a Super Key whose no proper subset is a Super
key)
Since all key will have PQS as an integral part, and we have proved that PQS is Candidate Key, Therefore, any
superset of PQS will be Super Key but not a Candidate key.
Since R has 9 attributes: - P, Q, R, S, T, U, V, W, X, and Candidate Key is PQS, Therefore, prime attributes (part
of candidate key) are P Q and S while a non-prime attribute is R T U V W X
Given FD are { PQ → R, QS → TU, PS → VW, and P → X } and Super Key / Candidate Key is PQS
NOTE: To solve such questions, we apply reverse engineering, i.e. 1st check BCNF, if not then 3NF, if not then
2NF, and so on.
a. FD: PQ → R does not satisfy the definition of BCNF, as PQ is not Super Key, hence the table is not in
BCNF (because if one dependency fails, all fails) now we check the same FD for 3NF.
b. FD: PQ → R even does not satisfy the definition of 3NF, as PQ is not Super Key or R is not a prime
attribute, hence table is not in 3NF also (because if one dependency fails, all fails) now we check same
FD for 2NF
c. FD: PQ → R even does not satisfy the definition of 2NF, as PQ is not Super Key and R which is not
prime attribute depending on part of the key (partial dependency), hence table is not in 2NF also
(because if one dependency fails, all fails).
Hence from the above three statements, we can say that table R ( P, Q, R, S, T, U, V, W, X) is in 1NF only.