0% found this document useful (0 votes)
2 views

Smu CS7330_Howework2

Uploaded by

unnathi.vithlani
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)
2 views

Smu CS7330_Howework2

Uploaded by

unnathi.vithlani
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/ 7

Homework 2

1. Let us solve this step by step.


a) Finding candidate keys:
Let's use the functional dependencies:
BE → A
CA → D
AB → E
First, let's find the closure of each proposed set:
For BC:
BC+:
- Start with BC
- Cannot immediately derive any other attributes
- Cannot get A (need E), cannot get D (need A), cannot get E (need A)
BC is NOT a candidate key
For BCE:
BCE+:
- Start with BCE
- Can get A (from BE)
- Can get D (from CA)
BCE+ = ABCDE
BCE is a candidate key
For ABC:
ABC+:
- Start with ABC
- Can get E (from AB)
- Can get D (from CA)
ABC+ = ABCDE
ABC is a candidate key
For ABCD:
Contains ABC which is already a candidate key, so not minimal

Answer: ii (BCE) and iii (ABC) are correct


b) Lossless decomposition:
A decomposition is lossless if the common attributes between relations
form a superkey for at least one relation.
i. ABCD, BCDE - Common attributes BCD
ii. ABE, BCDE - Common attributes BE
iii. AB, CDE - No common attributes
iv. DCA, EBCA - Common attributes CA
Options i and ii are lossless because:
- BCDE contains BCE which is a candidate key
- BE → A which makes BE determinant
Answer for b): Options i and ii are correct

c) Incompatible tuples:
Let's check each pair against the FDs:
i. (a1,b1,c1,d1,e1), (a1,b2,c2,d2,e2)
- Same A but different B and E violates BE → A
Cannot coexist
ii. (a1,b1,c1,d1,e1), (a1,b2,c1,d2,e1)
- Same C,A but different D violates CA → D
Cannot coexist
iii. (a1,b1,c1,d1,e1), (a1,b2,c1,d1,e2)
- Same A but different B and E violates AB → E
Cannot coexist
iv. (a1,b1,c1,d1,e1), (a1,b1,c2,d2,e1)
- No violation of FDs
Can coexist
Answer for c): Options i, ii, and iii are correct
Final answers:
a) ii and iii (BCE and ABC)
b) i and ii (ABCD,BCDE and ABE,BCDE)
c) i, ii, and iii

2) Let me solve this systematically.


a) Finding candidate keys:
1) Given FDs:
* A→B
* A→C
* CD→G
* EG→F
* AFG→E

2)
a) Let's find attribute closure systematically to find candidate keys:
We need all attributes not appearing on RHS as potential part of
candidate key:
* A appears on RHS of AFG→E
* D appears only on LHS
* E appears on RHS of AFG→E
* F appears on RHS of EG→F
* G appears on RHS of CD→G
Starting with AD (smallest combination of attributes not appearing on
RHS):
AD+ = {A,D}
* Using A→B: {A,B,D}
* Using A→C: {A,B,C,D}
* Using CD→G: {A,B,C,D,G}
* Using EG→F: Cannot use yet (missing E)
* Using AFG→E: Cannot use yet
Need to add E:
ADE+ = {A,D,E}
* Using A→B: {A,B,D,E}
* Using A→C: {A,B,C,D,E}
* Using CD→G: {A,B,C,D,E,G}
* Using EG→F: {A,B,C,D,E,F,G}
* Using AFG→E: Already have all attributes

Check minimality of ADE:


* AD+ cannot determine all attributes
* AE+ cannot determine all attributes
* DE+ cannot determine all attributes
Therefore, ADE is a candidate key and it's minimal.

b) Boyce-Codd normal form Decomposition:


Starting schema: R(A,B,C,D,E,F,G)
1) First iteration:
Check for BCNF violations: For any FD X→Y, X must be a superkey.
A→B violates BCNF (A is not a superkey)
Using leftmost FD A→B:
* R1(A,B)
* R2(A,C,D,E,F,G)
2) Check R2(A,C,D,E,F,G):
A→C violates BCNF
Decompose using A→C:
* R3(A,C)
* R4(A,D,E,F,G)
3) Check R4(A,D,E,F,G):
CD→G is not applicable (C not in R4)
EG→F and AFG→E remain but don't violate BCNF in R4 as they contain
multiple attributes and cannot determine more
Final BCNF decomposition:
* R1(A,B)
* R2(A,C)
* R3(A,D,E,F,G)
This decomposition is lossless because:
- Common attribute A is preserved across all relations
- A is part of the candidate key ADE

Final Answer:
a) The only candidate key is ADE
b) BCNF decomposition: R1(A,B), R2(A,C), R3(A,D,E,F,G)

3. Let me solve this step by step.


a) First, let's identify the functional dependencies (FDs):
From the bullet points:
* B → T (Each team has a hometown)
* BY → P (Every year, a player is on one and only one team)
* PY → M (Every year, a player can have one manager)
* MY → T (Every year, a manager only deals with teams from a certain
hometown)

b) Finding candidate keys:


First, let's understand what each attribute can determine.
For BMPTY table:
* B (team) → T
* BY → P
* PY → M
* MY → T
Let's find attribute closures:
1) Try BY:
BY+ = {B,Y}
* B→T: {B,Y,T}
* BY→P: {B,Y,T,P}
* PY→M: {B,Y,T,P,M}
BY can determine all attributes, let's check if it's minimal
2) Try removing Y from BY:
B+ = {B,T} - cannot determine all

3) Try removing B from BY:


Y+ = {Y} - cannot determine all
Therefore, BY is a minimal candidate key.
The candidate key is BY.

c) BCNF Analysis:
For BCNF, for every FD X→A, X must be a superkey.
Checking each FD:
1) B→T: B is not a superkey (B cannot determine all attributes)
2) BY→P: BY is a superkey (okay)
3) PY→M: PY is not a superkey
4) MY→T: MY is not a superkey
Therefore, the relation is NOT in BCNF because of violations from B→T,
PY→M, and MY→T.

d) 3NF Analysis:
For 3NF:
- Either X must be a superkey, OR
- A must be part of some candidate key
Checking each FD:
1) B→T:
- B is not a superkey
- T is not part of any candidate key
- Violates 3NF

2) BY→P:
- BY is a superkey
- Satisfies 3NF

3) PY→M:
- PY is not a superkey
- M is not part of any candidate key
- Violates 3NF

4) MY→T:
- MY is not a superkey
- T is not part of any candidate key
- Violates 3NF
Therefore, the relation is NOT in 3NF because multiple FDs violate
the conditions.

Final Answer:
a) FDs: B→T, BY→P, PY→M, MY→T
b) Candidate key: BY
c) Not in BCNF because B→T, PY→M, and MY→T violate BCNF
requirements (their LHS are not superkeys)
d) Not in 3NF because in multiple FDs (B→T, PY→M, MY→T), the RHS
attributes are not part of any candidate key and the LHS are not super
keys.

You might also like