0% found this document useful (0 votes)
10 views6 pages

hw2 Sols

This document is a homework assignment for a database systems course. It contains 4 questions related to functional dependencies, decompositions, and normal forms. Students are asked to determine which functional dependencies hold and are violated for a given schema, deduce dependencies, decompose relations, and determine if schemas satisfy different normal forms.

Uploaded by

m
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)
10 views6 pages

hw2 Sols

This document is a homework assignment for a database systems course. It contains 4 questions related to functional dependencies, decompositions, and normal forms. Students are asked to determine which functional dependencies hold and are violated for a given schema, deduce dependencies, decompose relations, and determine if schemas satisfy different normal forms.

Uploaded by

m
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/ 6

C ARNEGIE M ELLON U NIVERSITY

D EPARTMENT OF C OMPUTER S CIENCE


15-445/645 – DATABASE S YSTEMS (FALL 2017)
P ROF. A NDY PAVLO

Homework 2 (by Prashasthi Prabhakar) – Solutions


Due: Wednesday Sep 20, 2017 @ 11:59pm

IMPORTANT:
• Upload a PDF of your answers to Gradescope by 11:59pm on Wednesday Sep 20, 2017.
• Plagiarism: Homework may be discussed with other students, but all homework is to be
completed individually.
• Typeset all your answers.
For your information:
• Graded out of 100 points; 4 questions total
• Rough time estimate: ≈1-4 hours (0.5-1 hours for each question)
Revision : 2017/10/22 09:40

Question Points Score


Functional Dependencies I 15
Functional Dependencies II 32
Decompositions 20
Normal Forms 33
Total: 100

1
15-445/645 (Fall 2017) Homework 2 Page 2 of 6

Question 1: Functional Dependencies I . . . . . . . . . . . . . . . . . . . . . . . . [15 points]


GRADED BY: Mengran
Consider the following legal instance of a relational schema S with attributes XY Z:

S X Y Z
m 20 T
m 10 F
o 30 T
n 30 T
o 20 T
Table 1: Legal instance of schema S for question 2.1

(a) Which of the following dependencies are violated by the instances of S in Table 1?
i. [2 points]  Yes 2 No : X → Y is violated.
ii. [2 points]  Yes 2 No : Z → X is violated.
iii. [2 points] 2 Yes  No : Y → Z is violated.
iv. [2 points] 2 Yes  No : XY → Z is violated.
v. [2 points]  Yes 2 No : Y Z → X is violated.
vi. [2 points]  Yes 2 No : XZ → Y is violated.
(b) [3 points] By only observing the instance of S in Table 1, can you identify the functional
dependencies that hold on schema S? Why?
2 Yes  No

Solution: No, because we can only see an instance.

Homework 2 continues. . .
15-445/645 (Fall 2017) Homework 2 Page 3 of 6

Question 2: Functional Dependencies II . . . . . . . . . . . . . . . . . . . . . . . [32 points]


GRADED BY: Allison
For the next set of questions consider the relational schema R = {P, Q, R, S, T, U, V, W } and
the set of functional dependencies FD:

Q → U (1)
U → V (2)
PQ → W ST (3)
SU → TR (4)
VT → RW (5)
R → W (6)

(a) [8 points] Which of the following is a minimum cover of the FD? Mark all that qualify;
if none, mark accordingly, and give your own. answer.
i. The given FDs (Eq 1-6), is a minimum cover already.
ii. {Q → U, U → V, P Q → S, SU → T, SU → R, V T → R, V T → W, R → W }
iii. {Q → U, U → V, P Q → S, SU → T, P Q → W, V T → R, P Q → T, R → W }
iv. {Q → U, U → V, P Q → S, SU → T, V T → R, R → W }
v. {Q → U, U → V, P Q → S, SU → T, SU → R, V T → R, P Q → T, R → W }
vi. none of the above - the cover is
Solution: iv
(b) Yes/No: Which of the following functional dependencies can be deduced, from the above
set of functional dependencies (Eq. (1)-(6))?
i. [3 points]  Yes 2 No : Q → V
ii. [3 points] 2 Yes  No : QU → R
iii. [3 points]  Yes 2 No : SQ → T
iv. [3 points]  Yes 2 No : SQ → W
v. [3 points]  Yes 2 No : P Q → R
vi. [3 points] 2 Yes  No : V T → Q
(c) [3 points] True or False: The attribute closure {Q}+ is {Q, U, V }.
 True 2 False
(d) [3 points] True or False: The attribute closure {P Q}+ is {P, Q, W, S, T }.
2 True  False
Grading info: It is {P, Q, R, S, T, U, V, W }.

Homework 2 continues. . .
15-445/645 (Fall 2017) Homework 2 Page 4 of 6

Question 3: Decompositions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [20 points]


GRADED BY: Prashasthi
For this set of questions, consider the relation with attributes, X = {A, B, C, D, E, F }, Let
the following functional dependencies F D be defined over the relation X :

A→B
B → CD
E→F

(a) [2 points] Provide the attribute closure of {AB}.


Solution: {AB}+ = {ABCD}

(b) Consider the decomposition AB, BCD, EF . Mark ’True’ or ’False’:


i. [3 points] 2 True  False : It is lossless
ii. [3 points]  True 2 False : It is dependency-preserving
(c) Consider the decomposition AB, BCDF , EF . Mark ’True’ or ’False’:
i. [3 points] 2 True  False : It is lossless
ii. [3 points]  True 2 False : It is dependency-preserving
(d) Consider the decomposition ABCEF , EBD. Mark ’True’ or ’False’:
i. [3 points]  True 2 False : It is lossless
ii. [3 points]  True 2 False : It is dependency-preserving

Homework 2 continues. . .
15-445/645 (Fall 2017) Homework 2 Page 5 of 6

Question 4: Normal Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [33 points]


GRADED BY: Leon
Consider the relation with attributes, E = {P, Q, R, S}. Suppose that the following functional
dependencies hold:

PQ → R (7)
PQ → S (8)
R → P (9)
S → Q (10)

(a) [6 points] List all the candidate key(s) for E.


Solution: {P Q} , {QR} , {RS} , {P S}
Grading info: -2: for each missing candidate key
(b) [2 points] Is the relation E in BCNF? 2 Yes  No
(c) From the list below, select all applicable choices to justify whether E is (or is not) in
BCNF.
Note: when we refer to the main requirement for BCNF, we mean: every determinant is
a super key.
i. [1 point] 2 True  False : All FD’s satisfy the main requirement.
ii. [1 point] 2 True  False : FD (7) violates the main requirement.
iii. [1 point] 2 True  False : FD (8) violates the main requirement.
iv. [1 point]  True 2 False : FD (9) violates the main requirement.
v. [1 point]  True 2 False : FD (10) violates the main requirement.
(d) [2 points] Is the relation E in 3NF?  Yes 2 No
(e) From the list below, select all applicable choices to justify whether E is (or is not) in 3NF.
Note: when we refer to the secondary requirement for 3NF, we mean: for every FD
X → A, A is part of a candidate key.
i. [1 point]  True 2 False : All FD’s satisfy the secondary requirement.
ii. [1 point] 2 True  False : FD (7) violates the secondary requirement.
iii. [1 point] 2 True  False : FD (8) violates the secondary requirement.
iv. [1 point] 2 True  False : FD (9) violates the secondary requirement.
v. [1 point] 2 True  False : FD (10) violates the secondary requirement.
(f) [5 points] Give a 3NF decomposition of E that is lossless, dependency preserving, and
has as few tables as possible.
Solution: E1,1 =(P, Q, R, S)
Grading info: -1: 3NF decomposition with 2 tables; -3: 3NF decomposition more than with 2
tables; -4: 3NF decomposition with more than 5 tables

Question 4 continues. . .
15-445/645 (Fall 2017) Homework 2 Page 6 of 6

(g) [8 points] Give a BCNF decomposition of E that is lossless, and has as few tables as
possible.
Solution: E1,1 =(P, R), E1,2 =(Q, S), E1,3 =(R, S)
Grading info: -5: BCNF decomposition with more than 3 tables

End of Homework 2

You might also like