Docsity

Database Systems Homework: ER Diagrams, Functional Dependencies, and Normal Forms, Assignments of Deductive Database Systems

Toggle sidebar
bg1
CS411 Database Systems
Fall 2005
HW #1
Problem 1 ER diagram 15 pts
Figure 1 shows the ER diagram.
P๎˜r๎˜o๎˜j๎˜e๎˜c๎˜t๎˜
D๎˜e๎˜p๎˜a๎˜r๎˜t๎˜m๎˜e๎˜n๎˜t๎˜
S๎˜S๎˜N๎˜ N๎˜a๎˜m๎˜e๎˜ R๎˜a๎˜n๎˜k๎˜
P๎˜I๎˜D๎˜
S๎˜_๎˜D๎˜a๎˜t๎˜e๎˜
E๎˜_๎˜D๎˜a๎˜t๎˜e๎˜
D๎˜e๎˜p๎˜t๎˜N๎˜O๎˜
N๎˜a๎˜m๎˜e๎˜ O๎˜f๎˜f๎˜i๎˜c๎˜e๎˜
P๎˜r๎˜o๎˜f๎˜e๎˜s๎˜s๎˜o๎˜r๎˜
T๎˜i๎˜m๎˜e๎˜_๎˜P๎˜c๎˜t๎˜
W๎˜o๎˜r๎˜k๎˜I๎˜n๎˜ R๎˜u๎˜n๎˜
W๎˜o๎˜r๎˜k๎˜O๎˜n๎˜
M๎˜a๎˜n๎˜a๎˜g๎˜e๎˜
R๎˜e๎˜p๎˜r๎˜e๎˜s๎˜e๎˜n๎˜t๎˜s๎˜ ๎˜M๎˜a๎˜n๎˜y๎˜-๎˜t๎˜o๎˜-๎˜O๎˜n๎˜e๎˜ ๎˜r๎˜e๎˜l๎˜a๎˜t๎˜i๎˜o๎˜n๎˜s๎˜h๎˜i๎˜p๎˜
R๎˜e๎˜p๎˜r๎˜e๎˜s๎˜e๎˜n๎˜t๎˜s๎˜ ๎˜R๎˜e๎˜f๎˜e๎˜r๎˜e๎˜n๎˜t๎˜i๎˜a๎˜l๎˜ ๎˜I๎˜n๎˜t๎˜e๎˜g๎˜r๎˜i๎˜t๎˜y๎˜
Figure 1: ER Diagram 1
1
pf3
pf4
pf5

Partial preview of the text

Download Database Systems Homework: ER Diagrams, Functional Dependencies, and Normal Forms and more Assignments Deductive Database Systems in PDF only on Docsity!

CS411 Database Systems

Fall 2005

HW

Problem 1 ER diagram 15 pts

Figure 1 shows the ER diagram.

P r o je c t

D e p a r t m e n t

S S N N a m e R a n k P I D

S _ D a t e

E _ D a t e

D e p t N O N a m e O f f ic e

P r o f e s s o r

T i m e_ P ct

W o r k I n (^) R u n

W o r k O n

M a n a g e

R e p r e s e n t s M a n y - t o - O n e r e la t io n s h ip

R e p r e s e n t s R e f e r e n t ia l I n t e g r it y

Figure 1: ER Diagram 1

Problem 2 ER diagramโ€“ contโ€™d 15 pts

Figure 2 shows the ER diagram. The solid parts are those added on from the ER-diagram in Prob 1.

P r o f e s s o r P r^ o^ je^ c t

D e p a r t m e n t

S S N N a m e R a n k P I D

S _ D a t e

E _ D a t e

D e p t N O (^) N a m e O f f ic e

T i m e_ P ct

G r a d u a t e S t u d e n t

S S N

N a m e

P ro g ram

R e s e a r c h As s is t a n t O f f ic e

g r a d s e n io r

W o r k O n

M a n a g e

W o r k I n R u n

W o r k O n

Ad v ic e s

M a jo r I n

Figure 2: ER Diagram 2

Problem 3 ER basics 10 pts

Subclasses are used when there are certain entities in an entity set that have special properties not associated with all members of the set. We create an entity set for those entities with their special properties and/or relation- ships. One example is that for the entity set Graduate Student in Problem 2, we have some Graduate Students being Research Assistants. Therefore,

Problem 4 Schema Design 10pts

Professor(SSN , Name, Rank) Project(P ID, S Date, E Date) Department(DeptN O, Name, Office) WorkOn(SSN , P ID) Manage(SSN, P ID) WorkIN(SSN , DeptN O, Time Pct) Run(SSN, DeptN O)

If we use many-one relationship to reduce the number of relations, we could combine the Project relation with the Manage relation, and the De- partment relation with the run relation. Therefore, we will get: Professor(SSN , Name, Rank) Project(P ID, S Date, E Date, SSN) Department(DeptN O, Name, Office, SSN) WorkOn(SSN , P ID) WorkIN(SSN , DeptN O, Time Pct)

Problem 5 Functional Dependency 15 pts

(a) First we consider subset A. No FD could be found. Therefore, we have A+=A. For subset CD. We can get CD+=ABCD, using FDโ€™s CD โ†’ A and AD โ†’ B. For subset ABD. We can get ABD+=ABCD, using FD AB โ†’ C. (b) One way to deduce all dependencies is to consider the closures of all 15 nonempty subsets of attributes. To begin with, letโ€™s start with the subset with a single attributes, i.e., A+ = A, B+ = B, C+ = C, and D+ = D. Thus, there is no nontrivial dependency with a single attribute. Now consider the subset with a pair of attributes: From AB+ = ABCD, we get AB โ†’ D. From BC+ = ABCD, BC โ†’ A. From CD+ = ABCD, CD โ†’ B. From AD+ = ABCD, we get AD โ†’ C. For the subset with triples, the closures of the sets are ABCD, from which we get ABC โ†’ D, ABD โ†’ C, ACD โ†’ B, and BCD โ†’ A. Finally, from ABCD+ = ABCD, we get no new dependencies. Therefore, all the nontrivial FDโ€™s besides the ones are given are: AB โ†’ D, BC โ†’ A, CD โ†’ B, AD โ†’ C, ABC โ†’ D, ABD โ†’ C, ACD โ†’ B, and BCD โ†’ A.

(c) According to our development for (a), we find AB, BC, CD and AD are keys, as they have ABCD as their closures. (It is fine if the superkeys are also listed)

Problem 6 Normalization and Schema Design 10 pts

Before we start to finding any violations, we need to know all the nontrivial FDโ€™s. Follow the same scheme as Problem 5, we can get the following non- trivial FDโ€™s: B โ†’ D, AB โ†’ C, AB โ†’ D, BC โ†’ D, BE โ†’ C, BE โ†’ D, DE โ†’ C, ABC โ†’ D, ABE โ†’ C, ABE โ†’ D, ADE โ†’ C, ABCE โ†’ D, ABDE โ†’ C. From the FDโ€™s above, we can infer that the key for R is ABE.

(a) All the BCNF violations are: B โ†’ D, AB โ†’ C, AB โ†’ D, BC โ†’ D, BE โ†’ C, BE โ†’ D, DE โ†’ C, ABC โ†’ D, ADE โ†’ C.

(b) Suppose we decompose using AB โ†’ CD, which gives us ABCD and ABE as decomposed relations. ABE is in BCNF. but ABCD is not (vio- lations: B โ†’ D, BC โ†’ D). We further decompose ABCD by using FD B โ†’ D, which gives us BD and ABC. Both BD and ABC are in BCNF (Note, there can be multiple right answers, depending on which FDs used in which order.)

Problem 7 Normal Forms 15 pts

(a) in 3NF but not in BCNF Relation R(A, B,C, D) having FDโ€™s are AB โ†’ D, D โ†’ C, C โ†’ A. One of the FDโ€™s that violates BCNF is D โ†’ A as the keys for this relation are AB, BC and BD. However, there is no FD that violates 3NF. (b) in BCNF but not in 4NF Example 3.37 in the text book, Page 123. (c) in 4NF Relation R(A,B,C) having A as key. FDโ€™s are A โ†’ B, A โ†’ C. No violation.

Problem 8 Functional Dependency and Normal Forms

10 pts

Yes.