Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multivalued Dependencies. Intuition Redundancy: addresses, title repeated several times –because a star might have several addresses and stars in several.

Similar presentations


Presentation on theme: "Multivalued Dependencies. Intuition Redundancy: addresses, title repeated several times –because a star might have several addresses and stars in several."— Presentation transcript:

1 Multivalued Dependencies

2 Intuition Redundancy: addresses, title repeated several times –because a star might have several addresses and stars in several movies –yet, the relation is in BCNF (no nontrivial functional dependency) Reason: address and name are independent on each other namestreetcitytitleyear C. Fisher123 Map St.HollywoodStar Wars1977 C. Fisher5 Locust Ln.MalibuStar Wars1977 C. Fisher123 Map St.HollywoodEmpire Strikes Back1980 C. Fisher5 Locust Ln.MalibuEmpire Strikes Back1980 C. Fisher123 Map St.HollywoodReturn of the Jedi1983 C. Fisher5 Locust Ln.MalibuReturn of the Jedi1983 An instance of the Stars_in relation with address (street, city)

3 Intuition namestreetcitytitleyear C. Fisher123 Map St.HollywoodStar Wars1977 C. Fisher5 Locust Ln.MalibuEmpire Strikes Back1980 Can we reduce Stars_in to the following relation? What are the addresses of C. Fisher when he stars in Star Wars? How to avoid redundancy, yet still get the correct answer? namestreetcity C. Fisher123 Map St.Hollywood C. Fisher5 Locust Ln.Malibu nametitleyear C. FisherStar Wars1977 C. FisherEmpire Strikes Back1980 DECOMPOSITION WHAT IS THE GROUND FOR THIS DECOMPOSITION?

4 Multivalued Dependencies (MVD) A multivalued dependency is a statement about the fact that a set of attributes is independent from another set of attributes. Notation: A 1 A 2 …A n   B 1 B 2 …B m Meaning: for each pair of tuples t and u of R that agree on the A’s, we can find in R some tuple v that agrees: 1.With both t and u on the A’s 2.With t on the B’s 3.With u on the attributes that are not A’s or B’s

5 Illustration If A 1 A 2 …A n   B 1 B 2 …B m then for each pair t and u that agree on A’s we will find v such that v agrees with 1.t and u on A’s (green) 2.t on B’s(blue) 3.u on all others (red) A’s B’s t  u  MVD in picture Others v 

6 Example namestreetcitytitleyear C. Fisher123 Map St.HollywoodStar Wars1977 C. Fisher5 Locust Ln.MalibuEmpire Strikes Back1980 name   street city is a MVD of ‘Stars_in’ with address (street, city) (the A’s: name, the B’s {street, city}, others {title, year}) t  u  Because of t and u, the relation needs to contain the following tuple C. Fisher123 Map St.HollywoodEmpire Strikes Back1980 v  Switch t and u, we can conclude that the relation also needs to contain the following tuple: C. Fisher5 Locust Ln.MalibuStar Wars1977 v’  We can then reconstruct the first relation!

7 Nontrivial MVD A MVD of relation R A 1 …A n   B 1 …B m is nontrivial if –None of the B’s is among the A’s –Not all attributes of R belong to {A 1,…,A n }  {B 1,…,B m }

8 Reasoning about MVD Trivial dependencies rule: –if A 1 …A n   B 1 …B m then A 1 …A n   C 1 …C k where the C’s are the B’s plus some of the A’s –if A 1 …A n   B 1 …B m then A 1 …A n   D 1 …D r where the D’s are those B’s that are not among the A’s Transitive rule: if A 1 …A n   B 1 …B m and B 1 …B m   C 1 …C k then A 1 …A n   D 1 …D l where {D 1,…,D l } = {C 1,…,C k } \ {B 1,…,B m }

9 Reasoning about MVD If A 1 …A n  B 1 …B m then A 1 …A n   B 1 …B m If A 1 …A n   B 1 …B m then A 1 …A n   C 1 …C k where the C’s are all other attributes other than A’s and B’s (Complementation rule) NOTE: splitting/combining rules do not hold.

10 Fourth Normal Form (4NF) A relation R is in fourth normal form (4NF) if whenever there is a nontrivial MVD A 1 …A n   B 1 …B m, then {A 1,…,A n } is a superkey.

11 Decomposition into 4NF If R is not in 4NF then there exists a MVD A 1 …A n   B 1 …B m that violates the 4NF condition, we decompose R into 2 relations with the following schemas: –{A 1,…,A n,B 1,…,B m } –{A 1,…,A n,C 1,…,C k } where {C 1,…,C k } are those attributes of R that are not among the A’s and the B’s.

12 Example namestreetcitytitleyear C. Fisher123 Map St.HollywoodStar Wars1977 C. Fisher5 Locust Ln.MalibuEmpire Strikes Back1980 namestreetcity C. Fisher123 Map St.Hollywood C. Fisher5 Locust Ln.Malibu nametitleyear C. FisherStar Wars1977 C. FisherEmpire Strikes Back1980 DECOMPOSITION WHAT IS THE GROUND FOR THIS DECOMPOSITION? ANSWER: Because the MVD name   street city

13 Relationship among Normal Forms 4NF  BCNF  3NF Properties of NF and their decomposition Property3NF4NFBCNF Eliminates redundancy due to FD’sMostYes Eliminates redundancy due to MVD’sNoYesNo Preserves FD’sYesMaybe Preserves MVD’sMaybe

14 Homework 4 (Due Oct. 8) 3.6.1 For each of the following relation schemas and sets of FDs: a. R(A,B,C,D) with FDs AB  C, C  D, D  A b. R(A,B,C,D) with FDs B  C, B  D c. R(A,B,C,D) with FDs AB  C, BC  D, CD  A, AD  B do the following: i.Indicate all the BCNF violations. Decompose the relations, as necessary, into collections of BCNF relations. (10pt) ii.Indicate all the 3NF violations. Decompose the relations, as necessary, into collections of 3NF relations. (10pt)

15 Homework 4 (Due Oct. 8) 3.7.2 For each of the following relation schema and dependencies: a. R(A,B,C,D) with MVDs A  C, A  B b. R(A,B,C,D) with MVDs A  B, B  CD c. R(A,B,C,D) with MVDs AB  C and FD B  D do the following: i.Indicate all the 4NF violations. ii.Decompose the relations, as necessary, into collections of 4NF relations. (10pt)

16 Text for next class New edition (DBS the complete book): Chapter 4 Old edition (First course in DBS): –Section 2.1 –Section 2.3.4 –Section 2.4.1, 2.4.2 –Section 2.5.2 –Section 3.2 (ALL)


Download ppt "Multivalued Dependencies. Intuition Redundancy: addresses, title repeated several times –because a star might have several addresses and stars in several."

Similar presentations


Ads by Google