Feb 1, 2014 ... CS 440 - Assignment #1 - Solutions. 2. (15 pts) Exercise 10.17 on Page 372 in
Elmasri and Navathe. Student = {Sname, Snum, Ssn, Sc_addr, ...
CS 440 - Assignment #1 - Solutions
CS 440 Assignment #1 Solutions (total = 150 pts., due on Feb. 1, Monday)
(10 pts.) Access Database
Design View
Data view 1
CS 440 - Assignment #1 - Solutions
(15 pts) Exercise 10.17 on Page 372 in Elmasri and Navathe. Student = {Sname, Snum, Ssn, Sc_addr, Sc_phone, Bdate, Sex, Class, Major_code, Minor_code, Prog} Ssn → {Sname, Snum, Sc_addr, Sc_phone, Bdate, Sex, Class, Major_code, Prog} Snum → {Sname, Ssn, Sc_addr, Sc_phone, Bdate, Sex, Class, Major_code, Prog} Department = {Dname, Dcode, Doffice, Dphone, Dcollege} Dname → {Dcode, Doffice, Dphone, Dcollege} Dcode → {Dname, Doffice, Dphone, Dcollege} Course = {Cname, Cdesc, Cnum, Credit, Level, Cdept} Cnum → {Cname, Cdesc, Credit, Level, Cdept} Section = {Iname, Semester, Year, Sec_course, Sec_num} {Semester, Year, Sec_course, Sec_num} → Iname Grade_record = {Ssn, Semester, Year, Sec_course, Sec_num, Grade} {Ssn, Semester, Year, Sec_course, Sec_num}→ Grade
2
CS 440 - Assignment #1 - Solutions
(15 pts) Exercise 10.18 on Page 373 in Elmasri and Navathe. a. Proof of {W → Y, X → Z}╞ {WX → Y} 1. W → Y ╞ WX → YX (using augmentation rule IR2) 2. YX → Y (using reflexive rule IR1 and knowing that YX ⊇ Y) 3. WX → Y (using transitive rule IR3 on 1 and 2) b. Proof of {X → Y} and Y ⊇ Z ╞ {X → Z} 1. X → Y (given) 2. Y → Z (using IR1 and knowing Y ⊇ Z) 3. X → Z (using IR3 on 1 and 2) c. Proof {X → Y, X → W, WY → Z} ╞ {X → Z} 1. X → W (given) 2. XY → WY (using IR2 on 1 by augmenting with Y) 3. X → Y (given) 4. X → XY (using IR2 on 1 by augmenting with X; notice that XX = X) 5. X → WY (using IR3 on 2 and 4) 6. WY → Z (given) 7. X → Z (using IR3 on 4 and 5) d. Disproof of {XY → Z, Y → W} ╞ {XW → Z} Consider the relation instance as below: X
Y
Z
W
0
0
0
0
0
1
1
0
XY → Z and Y → W are satisfied. But XW → Z is not satisfied because with the same value (0, 0) of (X, W) in the first and the second record, the coresponding values of Z are different. e. Disproof of {X → Z, Y → Z} ╞ {X → Y} Consider the relation instance as below: X
Y
Z
0
0
1
0
1
1
X → Z, Y → Z are satisfied.
3
CS 440 - Assignment #1 - Solutions
But X → Y is not satisfied because with the same value 0 of X in the first and the second record, the coresponding values of Y are different. f. Proof of {X → Y, XY → Z} ╞ {X → Z} 1. X → Y (given) 2. X → XY (using IR2 on 1 by augmenting with X; notice that XX = X) 3. XY → Z (given) 4. X → Z (using IR3 on 2 and 3) g. Proof of {X → Y, Z → W} ╞ {XZ → YW} 1. X → Y (given) 2. XZ → YZ (using IR2 on 1 by augmenting with Z) 3. Z → W (given) 4. YZ → YW (using IR2 on 3 by augmenting with Y) 5. XZ → YW (using IR3 on 2 and 4) h. Disproof of {XY → Z, Z → X} ╞ {Z → Y} Consider the relation instance as below: X
Y
Z
0
0
1
0
1
1
XY → Z and Z → X are satisfied. But Z → Y is not satisfied because with the same value 0 of Z in the first and the second record, the coresponding values of Y are different. i. Proof of {X → Y, Y → Z} ╞ {X → YZ} 1. Y → Z (given) 2. Y → YZ (using IR2 on 1 by augmenting with Y; notice that YY = Y) 3. X → Y (given) 4. X → YZ (using IR3 on 2 and 3) j. Disproof of {XY → Z, Z → W} ╞ {X → W} Consider the relation instance as below: X
Y
Z
W
0
0
0
0
0
1
1
1
XY → Z, Z → W are satisfied.
4
CS 440 - Assignment #1 - Solutions
But X → W is not satisfied because with the same value 0 of X in the first and the second record, the coresponding values of W are different.
5
CS 440 - Assignment #1 - Solutions
(15 pts) Exercise 10.21 on Page 373 in Elmasri and Navathe. No, G is not minimal. Algorithm 10.2 (page 354) should be used to find a minimal set of functional dependencies G’ that is equivalent to G. G’ = {Ssn → Ename, Ssn → Bdate, Ssn → Address, Ssn → Dnumber, Dnumber → Dname, Dnumber → Dmgr_ssn} Definition of equivalent sets of functional dependencies (page 353) should be used to prove that G’ is equivalent to G.
6
CS 440 - Assignment #1 - Solutions
(15 pts) Exercise 10.28 on Page 374 in Elmasri and Navathe. a. i. A → B: cannot hold. Tuples #1 and #2 cause the violation. t1[A] = t2[A] but t1[B] ≠ t2[B]. ii. B → C: may hold. iii. C → B: cannot hold. Tuples #1 and #3 cause the violation. t1[C] = t3[C] but t1[B] ≠ t3[B]. iv. B → A: cannot hold. Tuples #1 and #5 cause the violation. t1[B] = t5[B] but t1[A] ≠ t5[A]. v. C → A: cannot hold. Tuples #1 and #3 cause the violation. t1[C] = t3[C] but t1[A] ≠ t3[A]. b. Yes, a potential candidate key is (A, B) or (A, C).
7
CS 440 - Assignment #1 - Solutions
(15 pts) Exercise 10.32 on Page 375 in Elmasri and Navathe. * Normal Forms The relation is in 1NF because it does not have multivalued nor composite attributes. The relation is NOT in 2NF because the functional dependency Salesman# → Commission% makes Commission% partially dependent on the primary key {Car#, Salesman#}, which violates the 2NF requirement. The relation is NOT in 3NF because of the transitive dependency of Discount_amt on the primary key via Date_sold. * Normalization The original CAR_SALE should be decomposed as below: 2NF: R1 (Car#, Date_sold, Salesman#, Discount_amt) R2 (Salesman#, Commission%) 3NF: R1 (Car#, Date_sold, Salesman#) R2 (Salesman#, Commission%) R3 (Date_sold, Discount_amt)
8
CS 440 - Assignment #1 - Solutions
(15 pts) Exercise 10.35 on Page 375 in Elmasri and Navathe. A → E (given) AB → E (augmentation rule) AB → C (given) AB → CE (union rule) CE → D (given) AB → D (transitive rule) That means AB → D can be inferred from the the given set of dependencies. In other words, AB → D is in the closure of the the given set of dependencies.
9