Alan K.
Dippel
CSC 570/671
November 9,1998
Professor: Fred Sadri
University of North
Carolina at Greensboro
Department of Mathematical Sciences
Assignment 5
http://www.cs.indiana.edu/~adippel/csc671/assignment5.htm
Question 1 (25%)
Consider the relational scheme
Library = { branch, address, isbn, title, author, publisher, copyNo }
with the following FDs
branch
à address(a) (5%) find all candidate keys of library. Show your work.
F = {branch
à address; isbn à title, publisher }Solving for canonical cover
{isbn}+ = {isbn, title, publisher},
F1 = {branch
à address; branch à publisher }F2 = {branch
à address; branch à title }therefore Fc = F.
R = {branch, address, isbn, title, author, publisher, copyNo}
Fc = {branch
à address, isbn à title, publisher}Looking at the right sides of the Functional Dependencies we see that the missing fields are branch, isbn, author, copyNo.
Checking to see if this is a candidate key.
{branch, isbn, author, copyNo}+ = {branch, address, isbn, title, author, publisher, copyNo} = R
Since this is a candidate key for Library and it has been proven that if the attributes that are missing on the right side of the Functional dependencies are in the key then only one unique candidate key exists, the following is true:
Candidate Key = {branch, isbn, author, copyNo}
(b) (10%) Give a lossless and dependency preserving decomposition of library into 3NF relations. Show your work
R is not in 3NF since the Functional dependencies are not all trivial. The canonical cover of the relations is Fc. We can decompose the table into three tables using the attributes of Fc and the candidate key per the 3NF algorithm. The candidate key must be used since it is not contained on the left side of the FDs.
Fc = {branch à address, isbn à title, publisher}
Candidate Key = {branch, isbn, author, copyNo}
R1 = {branch, address}
R2 = {isbn, title, publisher}
R3 = {branch, isdn, author, copyNo}
(c) (5%) For each scheme in your decomposition of part (b), determine whether it is in BCNF or not. Show your work.
R1 = {branch, address}
F1 = {branch
{branch}+ = {branch,address} OK branch is a superkey of R1.
R2 = {isbn, title, publisher}
F2 = {isbn
{isbn}+ = {isbn, title, publisher} OK isbn is a superkey of R2.
R3 = {branch, isdn, author, copyNo}
F3 = {} OK since all functional dependencies are trivial.
(d) (5%) Do any of the 3NF relation schemes in your decomposition of part (b) have the possibility of having redundancy in their data (instances)? If so, give examples that demonstrate redundancies.
No, if the 3NF algorithm is used to decompose a relation and the relations are also BCNF it has been proven there will be no redundancy in the data.
Question 2. (25%)
Consider the relation scheme
R = {A, B, C, D, E, F, G, H }
With the FDs
A
(a) (15%) find a canonical cover of the given set of FDs. Show your work.
R = {A, B, C, D, E, F, G, H}
F = {
A
There are no duplicates on the left side of the FDs, therefore we start eliminating extraneous attributes.
Eliminating B in ABE à CDGH
F1 = {
A à BC
AE à CDGH
C à GD
D à G
E à F } ABE+(wrt F) = {A, B, E, C, D, G, H, F};
ABE+(wrt F1) = {A, E, C, D, G, H, F, B} , therefore B is Extraneous
on the left.
There are no more extraneous attributes on the left.
Eliminating C in A à BC
F2 = {
A
Eliminating B in A
à BCF3 = {
A
Eliminating C in AE
à CDGHF4 = {
A
Eliminating D in AE
à DGHF5 = {
A
Eliminating G in AE
à GHF6 = {
A
Eliminating G in C
à GDF7 = {
A
Fc = F7 = {
A
(b) (5%) find all candidate keys of R. Show your work.
Looking at the FDs in Fc we see that the following attributes are missing from the right:
{A, E }
Testing this for a candidate key we find that {A, E }+ = {A, E, B, C, H, D, G,
F } therefore {A,E } is a candidate key and is a unique one as proven in the text.
(c) (5%) Give a lossless and dependency preserving decomposition of R into 3NF relations. Show your work.
Using the 3NF algorithm, start by taking the attributes of the Functional dependencies in Fc , we get the following relations.
R1 = {A, B, C }
R2 = {A, E, H }
R3 = {C, D }
R4 = {D, G }
R5 = {E, F }
These are all of the relations since the candidate key is contained within one of the
relations.
Question 3.
(20%)(a) Consider the following relation instance r. For each of the FDs f listed below, determine if r satisfies f. Justify your answers.
A |
B |
C |
D |
a1 |
b1 |
c1 |
d1 |
(a1) (5%) A
à Dr violates A
à D, the first and third tuples {a1, b1, c1, d1 } and {a1, b2, c2, d2 } have a different d attribute for the same a attribute. NOT OK(a2) (5%) AB
à Dr satisfies f since all the {a, b} attribute pairs are different. OK
(a3) (5%) AC
à Dr, satisfies f since the only {a, c} pairs that are equal have the same {d} attribute,
{a2, b2 c2, d1} and {a2, b1, c2, d1} OK
(b) (5%) Write a relation instance with two tuples on the scheme R = {E, F, G, H } that satisfies EF
à H and FG à H but violates F à H. Justify that your relation instance satisfies the first two FDs and violates the third.E |
F |
G |
H |
E1 |
F1 |
G1 |
H1 |
{ E1, F1
à H1; E2, F1 à H2 } satisfies the first FD(a) (6%) List the 3 conditions that a "good decomposition" should have.
(b) (24%) Given R = {A, B, C, D }, and the set of FDs A à BC, B à D evaluate each of the following decomposition's with respect to its "goodness" (i.e. with respect to the 3 conditions)
(b1) R1 = {A, B, C }, R2 = {A, D }.
Relations are "good" (i.e. no redundancy of data since R1 has all the
attributes of the first FD and the second relation has only trivial dependencies)
The decomposition has all of the attributes and is lossless.
The decomposition is NOT dependency preserving, since the B à D dependency is not used.
(b2) R1 = {A, B, C }, R2 = {B, D }.
Relations are "good"
The decomposition has all of the attributes and is lossless.
The decomposition is dependency preserving, since the A à BC, B à D
dependencies are there.
(b3) R1 = {A, B, C }, R2 = {C, D }.
Relations are NOT "good" since C à D is not implied by the FDs.
The decomposition has all of the attributes and is lossless.
The decomposition is NOT dependency preserving, since the B à D dependency is not used.
(b4) R1 = {A, B, D }, R2 = {A, C }.
Relations are NOT "good", since AB à D is not implied by the FDs.
The decomposition has all of the attributes and is lossless.
The decomposition is NOT dependency preserving, since the AB à C and B à D dependencies are not used.
http://www.uncg.edu/~akdippel/csc671/assignment5.htm