hw3KEY

October 14, 2017 | Author: quang140788 | Category: Computer Data, Data Management, Software Design, Data Model, Areas Of Computer Science
Share Embed Donate


Short Description

Download hw3KEY...

Description

COP 4710 – Database Systems – Spring 2004 Homework #3 – 115 points

KEY

Due: In class Wednesday March 31st. NO LATE ASSIGNMENTS ACCEPTED Answer each of the following questions completely. Make sure that your answers are neatly written and very readable. Points will be deducted if your assignment is not presented in a neat format. For example, don’t turn it in on notebook paper torn out of a spiral notebook. Problem #1 (10 points each) (a) Find a non-redundant cover for the set of functional dependencies F shown below. (b) If G = {A → BC, A → D, CD → E} is G equivalent to F? Let F = { A → BC, A → E, A → AB, A → D, CD → E}

(a)

SOLUTION does G = F − {A → BC} ⊨ A → B? Since (AG)+ = {A, C, E, B, D} , (AG)+ ⇒ A → B, so it is redundant. Remove A → B from G. does G = G − {A → C} ⊨ A → C? Since (AG)+ = {A, E, B, D} , (AG)+ ⇏ A → C, so it is not redundant. Do not remove A → C from G. does G = G − {A → E} ⊨ A → E? Since (AG)+ = {A, C, B, D, E} , (AG)+ ⇒ A → E, so it is redundant. Remove A → E from G. does G = G − {A → A} ⊨ A → A? Remove A → A from G, this is a trivial fd. does G = G − {A → B} ⊨ A → B? Since (AG)+ = {A, C, D} , (AG)+ ⇏ A → C, so it is not redundant. Do not remove A → B from G. does G = G − {A → D} ⊨ A → D? Since (AG)+ = {A, C, B} , (AG)+ ⇏ A → D, so it is not redundant. Do not remove A → D from G. does G = G − {CD → E} ⊨ CD → E? Since (AG)+ = {C, D} , (AG)+ ⇏ CD → E, so it is not redundant. Do not remove CD → E from G.

(b)

(AF)+ = {A, B, C, D, E}

(AG)+ = {A, B, C, D, E}

(CDF)+ = {C, D, E}

(CDG)+ = {C, D, E}

Yes, they are equivalent.

Problem #2 (10 points) Given the relational scheme R = (A, D, E, M, T, X, Z) and the set of functional dependencies F, shown below, find (XD)+. Is (XD) a key for R? Let F = {X → E, AT → Z, ME → T, AT → D, MT → A, XA → D, D → M} SOLUTION (XD)+ = {X, D, E, N, T, A, Z} Yes, (XD) is a key for R with respect to F.

Problem #3 (10 points) Given the set of functional dependencies F shown below, does (a) F logically imply AD → C, and (b) F logically imply AB → CE? Let F = { A → B, BD→ C, D → E, B → CA, C → E} SOLUTION (a) (AD)+ = {A, D, B, C, E} Yes, F ⊨ AD → C (b) (AB)+ = {A, B, C, E} Yes, F ⊨ AB → C and AB → E

Problem #4 (60 points total - 5 points each) COP 4710 Homework #2 - 2

Given the relation instance r(R) shown below, determine which of the functional dependencies listed hold on r(R).

A

relation r(R) B C D

E

a

a

x

r

d

m

e

x

m

a

r

e

x

m

t

b

f

a

b

a

z

a

c

a

b

b

r

a

c

a

a

c

y

m

s

b

r

r

c

e

C →B B →C B → CD A → CE

DE → A CD→ B

only 4 fds satsified

CE → A AB → D

DB→ A DB→ AE E → CA ECA → B

Problem #5 (15 points) Given the relational scheme R = (A,B,C,D,E,F,G,H), the set of functional dependencies X = {B → E, C → E, EF → G, G → ABH}, and the decomposition scheme Y = {(ABFG), (BC), (CDFH), (AEH)}, determine if Y has the lossless join property and preserves the dependencies. Test for lossless join property.

A

B

C

D

E

F

G

H

ABFG

a1

a2

b13

b14

b15

a6

a7

b18

BC

b21

a2

a3

b24

b25

b26

b27

b28

CDFH

b31

b32

a3

a4

b35

a6

b37

a8

AEH

a1

b42

b43

b44

a5

b46

b47

a8

initial table

Pass #1 through fds: COP 4710 Homework #2 - 3

B → E equates b15, b25 C → E equates b15, b35 EF → G equates a7, b37 G → A equates a1, b31 G → B equates a2, b32 G → H equates a8, b18

A

B

C

D

E

F

G

H

ABFG

a1

a2

b13

b14

b15

a6

a7

a8

BC

b21

a2

a3

b24

b15

b26

b27

b28

CDFH

a1

a2

a3

a4

b15

a6

a7

a8

AEH

a1

b42

b43

b44

a5

b46

b47

a8

Table after first pass through the fds. Changed cells highlighted Pass #2 through fds: B → E equates nothing C → E equates nothing EF → G equates nothing G → A equates nothing G → B equates nothing G → H equates nothing No changes – no row in the table contains all a symbols, so decomposition does not have the lossless join property. Note: This problem illustrates that simply checking for the inclusion of a key in one of the decomposition schemas is not sufficient to determine the lossless join property. In this case, (CDF) is a key for the relation schema but as shown above, the decomposition is not lossless. Y does not preserve the functional dependencies, since G = πX(ABFG) ∪ πX(BC) ∪ πX(CDH) ∪ πX(ABE) (CG)+ = {C} so G ⊭ C → E Problem #6 (10 points) Given the relation scheme R = (D, S, M, Q) and the set of functional dependencies F = {D → M, DS → Q}, determine if R is in 2NF? If so, simply state yes, if not, explain why it isn’t. SOLUTION D+ = {D, M} S+ = {S} M+ = {M} COP 4710 Homework #2 - 4

Q+ = {Q} (DS)+ = {D, S, M, Q} key (DM)+ = {D, M} (DQ)+ = {D, Q, M} (SM)+ = {S, M{ (SQ)+ = {S, Q} (MQ)+ = {M, Q} (DSM)+ = {D, S, M, Q} superkey (DQS)+ = {D, Q, S, M} superkey (SMQ)+ = {S, M, Q} (DMQ)+ = {D, M, Q} Since DS is the only candidate key for R, no, R is not in 2NF. D and S are prime attributes, M and Q are non-prime attributes. M is partially dependent on the key DS since DS → M, yet D → M. Therefore R is not in 2NF since a non-prime attribute (M) is partially dependent on the key (DS).

COP 4710 Homework #2 - 5

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF