0% found this document useful (0 votes)
16 views14 pages

DBMS W06 Pas

The document discusses various relational schemas and their functional dependencies, assessing their normal forms including BCNF, 3NF, 2NF, and 1NF. It provides solutions to multiple-choice questions regarding the normalization of schemas and the implications of functional dependencies. The document also includes examples of multivalued dependencies and their effects on schema decomposition.

Uploaded by

Harshdeep Sharma
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)
16 views14 pages

DBMS W06 Pas

The document discusses various relational schemas and their functional dependencies, assessing their normal forms including BCNF, 3NF, 2NF, and 1NF. It provides solutions to multiple-choice questions regarding the normalization of schemas and the implications of functional dependencies. The document also includes examples of multivalued dependencies and their effects on schema decomposition.

Uploaded by

Harshdeep Sharma
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/ 14

BSCCS2001: Practice with Solutions

Week 6
1. Consider the relational schema R(A, B, C, D, E), where the domains of A, B, C, D and
E include only atomic values. Identify the possible set of functional dependencies that
R can have such that R is in BCNF.
[MSQ: 2 points]

FD: {AB → CDE}
FD: {AB → CD, B → E}
FD: {AB → CD, C → D, D → E}
FD: {AB → CDE, D → A, E → B}

Solution: Given that in R each attribute is a single-valued attribute. Thus R is


already in 1NF.
Option-1: FD: {AB → CDE}
The only candidate key (thus primary key) is: AB as (AB)+ = {ABCDE}.
As all the non-prime attributes are fully functionally dependent on the candidate
key, it is already in 2NF.
{AB → CDE}, where AB is a superkey. Thus, it is in 3NF and also in BCNF.
Option-2: {AB → CD, B → E}
The only candidate key (thus primary key) is: AB as (AB)+ = {ABCDE}.
B → E is a partial functional dependency. Thus, it is in 1NF but not in 2NF.
Option-3: FD: {AB → CD, C → D, D → E}
The only candidate key (thus primary key) is: AB as (AB)+ = {ABCDE}.
There is no partial functional dependency. Thus, it is already in 2NF.
AB → CD, where AB is superkey.
But, for C → D, D → E

• the functional dependencies are not trivial.

• L.H.S of the functional dependencies are not superkeys.

• R.H.S of the functional dependencies are not prime attributes.

Thus, these two FDs violate 3NF rules. So, R is in 2NF but not in 3NF based on
this set of FDs.
Option-4: FD: {AB → CDE, D → A, E → B}
The candidate keys are: AB and DE as (AB)+ = {ABCDE} and (DE)+ =
{ABCDE}. The prime attributes are A, B, D, E.
There is no partial functional dependency. Thus, it is already in 2NF.
AB → CDE, where AB is superkey.
For D → A, E → B R.H.S of the functional dependencies are prime attributes.
Thus, it is in 3NF. However, These two FDs do not satisfy BCNF (as L.H.S are not
superkeys). So, R is in 3NF but not in BCNF based on this set of FDs.

Page 2
2. Consider the relational schema R(A, B, C, D, E, F ), where the domains for A, B, C, D, E
and F include atomic values only. If R satisfies the functional dependencies {AB →
CDE, E → F, BF → A, C → B}, then identify the correct statement(s).
[ MSQ: 2 points]
R is in 1NF but not in 2NF

R is in 2NF and also in 3NF

R is in 3NF but not in BCNF
R is in 3NF also in BCNF

Solution:
Candidate keys are: AB, BF, AC, BE, CF and CE. So, prime attributes are: A, B, C, E
and F . For the FDs: E → F and C → B, B and F are prime attributes. Thus,
there is no partial dependency, thus R is in 2NF.
AB → CDE and BF → A, as AB and BF both are candidate keys, the FDs are in
3NF.
C → B and E → F also in 3NF, since B and F are prime attributes. Thus, R is in
3NF.
C → B and E → F violate BCNF conditions as C and E are not superkeys. Thus,
R is not in BCNF.

Page 3
3. Consider the relational schema Z(P, Q, R, S ) and the following functional dependencies
on Z. [ MCQ: 2 points]

• P → QRS
• Q→R
• RS → P

Which of the following is/are correct?


Z is in 3NF and also in BCNF

Z is in 3NF but not in BCNF
Z is in 2NF but not in 3NF
Z is in BCNF but not in 3NF

Solution: FD = {P → QRS, Q → R, RS → P }
P + = PQRS
RS + = PQRS
QS + = PQRS
So, candidate keys are P, QS & RS and prime attribute are P, Q, R & S.
Since the schema Z has no partial dependencies or transitive dependencies, so it is
in 3NF.

Check for BCNF


P → QRS (P is candidate key) X
Q → R (Q is not candidate key) ×
RS → P (RS is candidate key) X

So, Z is in 3NF but not in BCNF.

Page 4
4. Let R(P,Q,R,S,T,U,V,W ) be a relation (all attributes have atomic values only) with
the following functional dependencies:

• {P Q → RST U }
• {P → R}
• {Q → S}
• {R → U V }
• {V → W }
• {W → U }
• {V → U }

Find the highest normal form in which the relation R is in.


[ MCQ: 2 points]

1NF
2NF
3NF
BCNF

Solution: Since all attributes in R have atomic values, it follows that R is in 1NF.

In order to check if R is in 2NF, we must find the candidate keys. Using the given
FDs, we find that PQV is the only candidate key. Hence P, Q and V are the prime
attributes and the rest are non-prime.
Now due to the presence of partial dependency, the relation R is not in 2NF.

Note: Partial dependency occurs when a non-prime attribute is functionally depen-


dent on a subset of a candidate key.

Page 5
5. Consider the instance of relation Course given in Figure 1. [ MSQ: 2 points]

Figure 1: An instance of relation Course

Which among the following multivalued dependencies can be inferred from the given
information?

course name →→ instructor
course name →→ book
course name →→ edition

course name →→ book, edition

Solution:
Let us first number the tuples as t1 , t2 , · · · , t10 .
Test for course name →→ instructor:
In relation Course, there exist two tuples t1 and t2 such that
t1 [course name] = t2 [course name].
We also have two tuples t3 and t4 in Course with the following properties:

• t1 [course name] = t2 [course name] = t3 [course name] = t4 [course name],

• t3 [instructor] = t1 [instructor] and t2 [instructor] = t4 [instructor],

• t1 [book, edition] = t2 [book, edition] and t3 [book, edition] = t4 [book, edition].

Thus it satisfies MVD conditions.


In the relation Course, there are three tuples t5 , t6 and t7 such that
t5 [course name] = t6 [course name] = t7 [course name].
We also have three tuples t8 , t9 and t10 in Course with the following properties:

• t5 [course name] = t6 [course name] = t7 [course name] = t8 [course name] =


t9 [course name] = t10 [course name],

Page 6
• t5 [instructor] = t6 [instructor] = t7 [instructor] and
t8 [instructor] = t9 [instructor] = t10 [instructor],

• t5 [book, edition] = t8 [instructor, edition],


t6 [book, edition] = t9 [instructor, edition]
and t7 [book, edition] = t10 [book, edition].

Thus, MVD conditions are satisfied.


Test for course name →→ book, edition:
MVD Complementation rule: In a relation R, if X →→ Y , then X →→ R − XY .
Since we already have course name →→ instructor, it follows that course name →→
book, edition also correct.
If we follow the same procedures as discussed above, we will be able to show that
the MVDs:
course name →→ book
course name →→ edition
are not satisfied on relation Course.

Page 7
6. Consider the relational schema:
Intern(intern code, intern name, project, hobby).
An intern can work in several projects and can have several hobbies. However, it main-
tains the FD: intern code → intern name.
Identify the most appropriate 4NF decomposition for the given schema.
[ MCQ: 2 points]
R1(intern code, intern name, project, hobby), R2(intern code, project, hobby)
R1(intern code, intern name, project), R2(intern code, hobby)
R1(intern code, intern name, hobby), R2(intern code, project)

R1(intern code, intern name), R2(intern code, project), R3(intern code, hobby)

Solution:
From the given information in the question, intern code cannot be a super key for
the given relation. Thus, intern code → intern name violates BCNF conditions.
Thus, a possible BCNF decomposition would be:
R1(intern code, intern name), where intern code is the candidate key, and
R2(intern code, project, hobby).
R2 violates 4NF conditions as it has the following MVDs:
intern code →→ project, and
intern code →→ hobby
So the 4NF decomposition is:
R2(intern code, project), and
R3(intern code, hobby).
Thus, the 4NF decomposition is:
R1(intern code, intern name),
R2(intern code, project),
R3(intern code, hobby).

Page 8
7. Let S(Y, U, V ) be a relation. Let R(P, W, X, Y, Z ) be another relation with the
following functional dependencies:
F = {X → ZW, Y → X, W → P }
R contains 300 tuples and S contains 250 tuples. What is the maximum number of
tuples possible as output of R o
n S?
[ MCQ: 2 point]
75000

250
300
50

Solution: From the given set of functional dependencies, Y is a candidate key of


relation R. So all 300 values of Y must be unique in R.
There is no functional dependency given for S and to get the maximum number of
tuples in output, there can be two possibilities for S.

• All 250 values of Y in S are same and there is an entry in R that matches with
this value. In this case, we get 250 tuples in output.

• All 100 values of Y in S are different and these values are present in R also.
In this case also, we get 250 tuples.

Page 9
8. Let A(T,U,V,W ) be a relational schema with the following functional dependencies:
F = {W → U T, U V → W, V → T, W → U }
It is given that A is not in BCNF.
Suppose A is decomposed into two relational schemas, B(TV ) and C(UVW ).
Which of the following statement(s) is/are correct?
[ MSQ: 2 points]
Decomposition of schema A into B and C is dependency preserving

Decomposition of schema A into B and C is lossless
Both B and C are in BCNF

Relation B is in BCNF

Solution:

• B(TV ) preserves {V → T } and has V as the candidate key. So, relation B is


in BCNF.

• C(UVW ) preserves {UV → W, W → U } and has UV and VW as the candi-


date keys. So, relation C is in 3NF but not in BCNF, as W is not a superkey.

• The decomposition of schema A into two relational schemas, B and C, does


not cover all the functional dependencies of the original relation A. Hence, it
is not dependency preserving.

• The decomposition has common attribute (i.e., V ) which is superkey of relation


B(TV ), so decomposition of A into B and C is lossless join decomposition.

Page 10
9. Consider the relational schema:
prescription(doctor id, doctor name, patient id, patient name, medicine id, medicine name),
where the domains of all the attributes consist of atomic values. Consider the following
FDs for the relation department.
[ MCQ: 2 points]

• doctor id → doctor name,


• patient id → patient name,
• medicine id → medicine name,
• doctor id →→ patient id,
• doctor id →→ medicine id

From among the decompositions given, identify the one that is in 4NF.
(doctor id, doctor name),
(patient id, patient name),
(medicine id, medicine name),
(doctor id, doctor name),
(patient id, patient name),
(medicine id, medicine name),
(doctor id, patient id, medicine id)
(doctor id, doctor name, patient id, patient name),
(doctor id, doctor name, medicine id, medicine name)

(doctor id, doctor name),
(patient id, patient name),
(medicine id, medicine name),
(doctor id, patient id),
(doctor id, medicine id)

Solution: For the given relation, the candidate key is {doctor id, patient id, medicine id}
and it is in 1NF. However, it is not in 2NF as the FDs:
doctor id → doctor name,
patient id → patient name,
medicine id → medicine name, are partial functional dependencies. Thus, a possi-
ble decomposition is:
R1(doctor id, doctor name), where doctor id is the candidate key,
R2(patient id, patient name), where patient id is the candidate key,
R3(medicine id, medicine name), where medicine id is the candidate key,
R4(doctor id, patient id, medicine id), where {doctor id, patient id, medicine id} is
the candidate key,
R1, R2, R3 and R4 are already in 3NF and BCNF.

Page 11
R1, R2 and R3 are already in 4NF. The MVDs,
doctor id →→ patient id, and
doctor id →→ medicine id violate 4NF conditions. Thus, R4 is decomposed as:
R41(doctor id, patient id) and
R42(doctor id, medicine id).
Thus, the 4NF decomposition is:
R1(doctor id, doctor name),
R2(patient id, patient name),
R3(medicine id, medicine name)
R41(doctor id, patient id) and
R42(doctor id, medicine id).

Page 12
10. Consider the relational schema R as:
R(A, B, C, D, E, F, G, H), where the domains of all the attributes consist of atomic
values. Consider the following FDs for the relation department.

• A → D,
• D → EF ,
• BH → CG,
• G → H,

From among the decompositions given, identify the one that is in BCNF.
[ MCQ: 2 points]

(A, D, E, F ), (G, H), (B, C, G, H) and (A, B, H)


(D, E, F ), (A, D), (G, H) and (B, C, G)

(D, E, F ), (A, D), (G, H), (B, C, G) and (A, B, H)
(D, E, F ), (A, D), (B, C, G, H) and (A, B, H)

Solution: Due to atomic values, the relation R is in 1NF.


Candidate key is: ABH as (ABH)+ = R.
Test for 2NF: FD: A → D and BH → CG violate 2NF conditions (these are
partial functional dependencies). Thus, the decomposition of R is:
Since (A)+ = ADEF , R1(A, D, E, F ), where A is the candidate key,
since (BH)+ = BHCG, R2(B, H, C, G), where BH is the candidate key, and
R3(A, B, H) consists of the original candidate key of R.
Now, R1, R2 and R3 are in 2NF.
Test for 3NF: In R1, FD D → EF violates 3NF conditions (as D is not a su-
perkey). Thus, the decomposition is:
R11(D, E, F ), where D is the candidate key and R12(A, D), where A is the candi-
date key.
The relations R3 and R2 are already in 3NF (since in R2, FD: G → H satisfies
3NF conditions as H is a prime attribute).
Test for BCNF: The relations R11, R12 and R3 are already in BCNF. However,
in relation R2, FD: G → H violates BCNF conditions as G is not a super key).
Thus, the decomposition is:
R22(G, H), where G is the candidate key and R22(B, C, G), where BCG is the
candidate key.
The final relations after decomposition are:
R11(D, E, F ), R12(A, D), R21(G, H), R22(B, C, G) and R3(A, B, H). Please
note that although the decomposition is lossless, it is not dependency preserving.

Page 13
11. Which of the following statements is/are true regarding temporal relations?
[ MSQ: 2 points]

A uni-temporal relation can have only valid time.


A uni-temporal relation can have only transaction time.

A uni-temporal relation can have either valid transaction time or transaction
time.

A bi-temporal relation can have both valid transaction time and transaction
time.

Solution:

• An uni-temporal relations has one axis of time, either valid time or transaction
time.

• A bi-temporal relation has both axis of time, valid time and transaction time.
It includes valid start time, valid end time, transaction start time, transaction
end time.

Page 14

You might also like