logging in or signing up MVD FunnyGuy Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 685 Category: Entertainment License: All Rights Reserved Like it (1) Dislike it (0) Added: June 26, 2007 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Multi-valued Dependencies and Fourth Normal Form: Multi-valued Dependencies and Fourth Normal Form COSC 6340 Topics Covered: Topics Covered Definition of Multivalued Dependencies Reasoning about MVDs Fourth Normal Form Motivation: Motivation There are schemas that are in BCNF that do not seem to be sufficiently normalized name street Stars city title year C. Fisher C. Fisher C. Fisher C. Fisher C. Fisher 123 Maple Str. 5 Locust Ln. 123 Maple Str. 5 Locust Ln. 123 Maple Str. 5 Locust Ln. C. Fisher Hollywood Malibu Hollywood Malibu Hollywood Malibu Star Wars 1977 Star Wars 1977 Empire Strikes Back 1980 Empire Strikes Back 1980 Return of the Jedi 1983 Return of the Jedi 1983 Attribute Independence: Attribute Independence No reason to associate address with one movie and not another When we repeat address and movie facts in all combinations, there is obvious redundancy However, NO BCNF violation in Stars relation There are no non-trivial FD’s at all, all five attributes form the only superkey Why? Multi-valued Dependency: Multi-valued Dependency Definition: Multivalued dependency (MVD): A1A2…An B1B2…Bm holds for relation R if: For all tuples t, u in R If t[A1A2...An] = u[A1A2...An], then there exists a v in R such that: (1) v[A1A2...An] = t[A1A2...An] = u[A1A2...An] (2) v[B1B2…Bm] = t[B1B2…Bm] (3) v[C1C2…Ck] = u[C1C2…Ck], where C1C2…Ck is all attributes in R except (A1A2...An B1B2…Bm) Pictorially Speaking...: Pictorially Speaking... An MVD guarantees v exists The existence of a fourth tuple w is implied by interchanging t and u t u A’s B’s Others v w Example: name street city: Example: name street city name street Stars city title year C. Fisher C. Fisher C. Fisher 123 Maple Str. 123 Maple Str. 5 Locust Ln. Hollywood Hollywood Malibu Star Wars 1977 Empire Strikes Back 1980 Empire Strikes Back 1980 t u v Example: name street city: Example: name street city name street Stars city title year C. Fisher C. Fisher C. Fisher C. Fisher 123 Maple Str. 5 Locust Ln. 123 Maple Str. 5 Locust Ln. Hollywood Malibu Hollywood Malibu Star Wars 1977 Star Wars 1977 Empire Strikes Back 1980 Empire Strikes Back 1980 u t w v More on MVDs: More on MVDs Intuitively, A1A2…An B1B2…Bm says that the relationship between A1A2…An and B1B2…Bm is independent of the relationship between A1A2…An and R -{B1B2…Bm} MVD's uncover situations where independent facts related to a certain object are being squished together in one relation Functional dependencies rule out certain tuples from being in a relation How? Multivalued dependencies require that other tuples of a certain form be present in the relation a.k.a. tuple-generating dependencies Let’s Illustrate: Let’s Illustrate In Stars, we must repeat the movie (title, year) once for each address (street, city) a movie star has Alternatively, we must repeat the address for each movie a star has made Example: Stars with name street city name street city title year C. Fisher C. Fisher C. Fisher 123 Maple Str. 5 Locust Ln. 123 Maple Str. Hollywood Malibu Hollywood Star Wars 1977 Empire Strikes Back 1980 Return of the Jedi 1983 Is an incomplete extent of Stars Infer the existence of a fourth tuple under the given MVD Trivial MVDs: Trivial MVDs Trivial MVD A1A2…An B1B2…Bm where B1B2…Bm is a subset of A1A2…An or (A1A2…An B1B2…Bm ) contains all attributes of R Reasoning About MVDs: Reasoning About MVDs FD-IS-AN-MVD Rule (Replication) If A1A2…An B1B2…Bm then A1A2…An B1B2…Bm holds Reasoning About MVDs: Reasoning About MVDs COMPLEMENTATION Rule If A1A2…An B1B2…Bm then A1A2…An C1C2…Ck where C1C2…Ck is all attributes in R except (A1A2…An B1B2…Bm ) AUGMENTATION Rule If XY and WZ then WX YZ TRANSITIVITY Rule If XY and YZ then X (Z-Y) Coalescence Rule for MVD: Coalescence Rule for MVD X Y W:W Z Then: X Z If: Remark: Y and W have to be disjoint and Z has to be a subset of or equal to Y Definition 4NF: Definition 4NF Given: relation R and set of MVD's for R Definition: R is in 4NF with respect to its MVD's if for every non-trivial MVD A1A2…AnB1B2…Bm , A1A2…An is a superkey Note: Since every FD is also an MVD, 4NF implies BCNF Example: Stars is not in 4NF Decomposition Algorithm: Decomposition Algorithm (1) apply closure to the user-specified FD's and MVD's**: (2) repeat until no more 4NF violations: if R with AA -andgt;andgt; BB violates 4NF then: (2a) decompose R into R1(AA,BB) and R2(AA,CC), where CC is all attributes in R except (AA BB) (2b) assign FD's and MVD's to the new relations** ** MVD's: hard problem! No simple test analogous to computing the attribute closure for FD’s exists for MVD’s. You are stuck to have to use the 5 inference rules for MVD’s when computing the closure! Exercise: Exercise Decompose Stars into a set of relations that are in 4NF. namestreet city is a 4NF violation Apply decomposition: R(name, street, city) S(name, title, year) What about namestreet city in R and nametitle year in S? Exercise: Exercise For the relation R(A,B,C,D) with only MVD’s AB and AC find all 4NF violations and decompose R into a collection of relation schemas in 4NF. Solution: Solution Since there are no functional dependencies, the only key is all four attributes, ABCD. Thus, each of the nontrivial multivalued dependencies A-andgt;-andgt;B and A-andgt;-andgt;C violate 4NF. Separate out the attributes of these dependencies, first decomposing into AB and ACD Then decompose the latter into AC and AD because A-andgt;-andgt;C is still a 4NF violation for ACD. The final set of relations are AB, AC, and AD. Exercise: Exercise Suppose we have relation R(A,B,C) with MVD AB. If we know that the tuples (a,b1,c1), (a,b2,c2), and (a,b3,c3) are in the current instance of R, what other tuples do we know must also be in R? Solution: Solution Since A-andgt;-andgt;B, and all the tuples have the same value for attribute A, we can pair the B-value from any tuple with the value of the remaining attribute C from any other tuple. Thus, we know that R must have at least the nine tuples of the form (a,b,c), where b is any of b1, b2, or b3, and c is any of c1, c2, or c3. That is, we can derive, using the definition of a multivalued dependency, that each of the tuples (a,b1,c2), (a,b1,c3), (a,b2,c1), (a,b2,c3), (a,b3,c1), and (a,b3,c2) are also in R. Another View of 4NF: ‘s Another View of 4NF MVD’s that are also FD’s True MVD’s Trivial MVD’s 4NF:= Relation is in BCNF and there are no true MVD’s (yellow part is empty) True MVD XY:= non-trivial andamp; XY does not hold Remark: If XY is a true MVD then X cannot be a superkey (because XY does not hold); Therefore, true MVD’s always violate 4NF ('true MVD’s are always bad) XY XY and XY XY and not XY H1-2005-Problem8: H1-2005-Problem8 8) Normalization [6] graded R(A,B,C,D,E,F) is given with: (1) ABCD (2)CDAB (3)ABF (4) FE What are the candidate keys of relation R? [1] b) Transform R into a relational schema that is in BCNF and does not have any lost functional dependencies! [5] Correct Solution: Candidate keys: AB and CD Decompose R into R1(A,B,C,D,F) with local FD’s (1), (2), (3) and R2(E,F) with local FD’s (4) Due to the fact that all four dependencies are still present no functional dependency has been lost. Moreover, all functional depencies are good A non-optimal ('too many relations') solution I also saw was: Decompose R into R1(A,B,C,D) with local functional dependencies ABCD and CDAB, R2(A,B,F) with local functional dependencies ABF and R3(F,E) with local functional dependencies FA.. Problem 1; H1-2004: Problem 1; H1-2004 Candidate keys are: {a,b}, {a,d}, {a,e} 14 superkeys total All but the first functional dependency are bad Problem 2; H2-04: Problem 2; H2-04 No; EBC is a 'true' multi-valued dependency and E is not a candidate key (as a matter of fact {E}+={A,D,E,F} see below) No (but just mentioning neither E ABC nor E CF holds is not sufficient (e.g. if EABC holds then the decomposition is lossless!) ) --- a counter examples should be given to show that the statement is false! Yes C is candidate key; therefore CBDEF; therefore CBDEF Yes E BC and BC BCD implies ED due to MVD-transitivity (CCDBCBCD BCBCD) Yes EBC; therefore EADF; moreover, CADF and using the Coalescence Rule we obtain EADF; therefore, EA holds No R is not in BCNF because EADF holds and E is not a candidate key. Problem 3a-2004: Problem 3a-2004 From AB and AC we can infer: ABC?? (1) AC AAC (2) AB ACABC (3) ACABC ACDE (4) AAC, ACDE ADE (5) ADE ABC Using: 1. Augmentation, 2.Augmentation, 3.Complementation, 4.Transitivity, 5. Complementation Wrong!! Remark: This problem will be revised in Homework3-2005; it is too complicated to worry about it for the midterm exam! MDV’s and FD’s --- Ungraded Homework: MDV’s and FD’s --- Ungraded Homework Assume we have a relation R(A,B,C,D,E) with the following dependencies: (1) AB CDE (2) CD ABE (3) E DB Answer the following questions giving reasons for your answers: a) Is R in BCNF? ????? (answer after Spring break) Warning: The presence of the MVD might imply other functional dependencies (see textbook page 637) b) Does ABE D hold for R? yes c) Does CD B hold for R? yes d) Does E D always hold for R (either show that this dependency can be inferred from the given 3 dependencies, or give a counter example of a relation that satisfies (1), (2), (3) but violates ED)? No You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
MVD FunnyGuy Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 685 Category: Entertainment License: All Rights Reserved Like it (1) Dislike it (0) Added: June 26, 2007 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Multi-valued Dependencies and Fourth Normal Form: Multi-valued Dependencies and Fourth Normal Form COSC 6340 Topics Covered: Topics Covered Definition of Multivalued Dependencies Reasoning about MVDs Fourth Normal Form Motivation: Motivation There are schemas that are in BCNF that do not seem to be sufficiently normalized name street Stars city title year C. Fisher C. Fisher C. Fisher C. Fisher C. Fisher 123 Maple Str. 5 Locust Ln. 123 Maple Str. 5 Locust Ln. 123 Maple Str. 5 Locust Ln. C. Fisher Hollywood Malibu Hollywood Malibu Hollywood Malibu Star Wars 1977 Star Wars 1977 Empire Strikes Back 1980 Empire Strikes Back 1980 Return of the Jedi 1983 Return of the Jedi 1983 Attribute Independence: Attribute Independence No reason to associate address with one movie and not another When we repeat address and movie facts in all combinations, there is obvious redundancy However, NO BCNF violation in Stars relation There are no non-trivial FD’s at all, all five attributes form the only superkey Why? Multi-valued Dependency: Multi-valued Dependency Definition: Multivalued dependency (MVD): A1A2…An B1B2…Bm holds for relation R if: For all tuples t, u in R If t[A1A2...An] = u[A1A2...An], then there exists a v in R such that: (1) v[A1A2...An] = t[A1A2...An] = u[A1A2...An] (2) v[B1B2…Bm] = t[B1B2…Bm] (3) v[C1C2…Ck] = u[C1C2…Ck], where C1C2…Ck is all attributes in R except (A1A2...An B1B2…Bm) Pictorially Speaking...: Pictorially Speaking... An MVD guarantees v exists The existence of a fourth tuple w is implied by interchanging t and u t u A’s B’s Others v w Example: name street city: Example: name street city name street Stars city title year C. Fisher C. Fisher C. Fisher 123 Maple Str. 123 Maple Str. 5 Locust Ln. Hollywood Hollywood Malibu Star Wars 1977 Empire Strikes Back 1980 Empire Strikes Back 1980 t u v Example: name street city: Example: name street city name street Stars city title year C. Fisher C. Fisher C. Fisher C. Fisher 123 Maple Str. 5 Locust Ln. 123 Maple Str. 5 Locust Ln. Hollywood Malibu Hollywood Malibu Star Wars 1977 Star Wars 1977 Empire Strikes Back 1980 Empire Strikes Back 1980 u t w v More on MVDs: More on MVDs Intuitively, A1A2…An B1B2…Bm says that the relationship between A1A2…An and B1B2…Bm is independent of the relationship between A1A2…An and R -{B1B2…Bm} MVD's uncover situations where independent facts related to a certain object are being squished together in one relation Functional dependencies rule out certain tuples from being in a relation How? Multivalued dependencies require that other tuples of a certain form be present in the relation a.k.a. tuple-generating dependencies Let’s Illustrate: Let’s Illustrate In Stars, we must repeat the movie (title, year) once for each address (street, city) a movie star has Alternatively, we must repeat the address for each movie a star has made Example: Stars with name street city name street city title year C. Fisher C. Fisher C. Fisher 123 Maple Str. 5 Locust Ln. 123 Maple Str. Hollywood Malibu Hollywood Star Wars 1977 Empire Strikes Back 1980 Return of the Jedi 1983 Is an incomplete extent of Stars Infer the existence of a fourth tuple under the given MVD Trivial MVDs: Trivial MVDs Trivial MVD A1A2…An B1B2…Bm where B1B2…Bm is a subset of A1A2…An or (A1A2…An B1B2…Bm ) contains all attributes of R Reasoning About MVDs: Reasoning About MVDs FD-IS-AN-MVD Rule (Replication) If A1A2…An B1B2…Bm then A1A2…An B1B2…Bm holds Reasoning About MVDs: Reasoning About MVDs COMPLEMENTATION Rule If A1A2…An B1B2…Bm then A1A2…An C1C2…Ck where C1C2…Ck is all attributes in R except (A1A2…An B1B2…Bm ) AUGMENTATION Rule If XY and WZ then WX YZ TRANSITIVITY Rule If XY and YZ then X (Z-Y) Coalescence Rule for MVD: Coalescence Rule for MVD X Y W:W Z Then: X Z If: Remark: Y and W have to be disjoint and Z has to be a subset of or equal to Y Definition 4NF: Definition 4NF Given: relation R and set of MVD's for R Definition: R is in 4NF with respect to its MVD's if for every non-trivial MVD A1A2…AnB1B2…Bm , A1A2…An is a superkey Note: Since every FD is also an MVD, 4NF implies BCNF Example: Stars is not in 4NF Decomposition Algorithm: Decomposition Algorithm (1) apply closure to the user-specified FD's and MVD's**: (2) repeat until no more 4NF violations: if R with AA -andgt;andgt; BB violates 4NF then: (2a) decompose R into R1(AA,BB) and R2(AA,CC), where CC is all attributes in R except (AA BB) (2b) assign FD's and MVD's to the new relations** ** MVD's: hard problem! No simple test analogous to computing the attribute closure for FD’s exists for MVD’s. You are stuck to have to use the 5 inference rules for MVD’s when computing the closure! Exercise: Exercise Decompose Stars into a set of relations that are in 4NF. namestreet city is a 4NF violation Apply decomposition: R(name, street, city) S(name, title, year) What about namestreet city in R and nametitle year in S? Exercise: Exercise For the relation R(A,B,C,D) with only MVD’s AB and AC find all 4NF violations and decompose R into a collection of relation schemas in 4NF. Solution: Solution Since there are no functional dependencies, the only key is all four attributes, ABCD. Thus, each of the nontrivial multivalued dependencies A-andgt;-andgt;B and A-andgt;-andgt;C violate 4NF. Separate out the attributes of these dependencies, first decomposing into AB and ACD Then decompose the latter into AC and AD because A-andgt;-andgt;C is still a 4NF violation for ACD. The final set of relations are AB, AC, and AD. Exercise: Exercise Suppose we have relation R(A,B,C) with MVD AB. If we know that the tuples (a,b1,c1), (a,b2,c2), and (a,b3,c3) are in the current instance of R, what other tuples do we know must also be in R? Solution: Solution Since A-andgt;-andgt;B, and all the tuples have the same value for attribute A, we can pair the B-value from any tuple with the value of the remaining attribute C from any other tuple. Thus, we know that R must have at least the nine tuples of the form (a,b,c), where b is any of b1, b2, or b3, and c is any of c1, c2, or c3. That is, we can derive, using the definition of a multivalued dependency, that each of the tuples (a,b1,c2), (a,b1,c3), (a,b2,c1), (a,b2,c3), (a,b3,c1), and (a,b3,c2) are also in R. Another View of 4NF: ‘s Another View of 4NF MVD’s that are also FD’s True MVD’s Trivial MVD’s 4NF:= Relation is in BCNF and there are no true MVD’s (yellow part is empty) True MVD XY:= non-trivial andamp; XY does not hold Remark: If XY is a true MVD then X cannot be a superkey (because XY does not hold); Therefore, true MVD’s always violate 4NF ('true MVD’s are always bad) XY XY and XY XY and not XY H1-2005-Problem8: H1-2005-Problem8 8) Normalization [6] graded R(A,B,C,D,E,F) is given with: (1) ABCD (2)CDAB (3)ABF (4) FE What are the candidate keys of relation R? [1] b) Transform R into a relational schema that is in BCNF and does not have any lost functional dependencies! [5] Correct Solution: Candidate keys: AB and CD Decompose R into R1(A,B,C,D,F) with local FD’s (1), (2), (3) and R2(E,F) with local FD’s (4) Due to the fact that all four dependencies are still present no functional dependency has been lost. Moreover, all functional depencies are good A non-optimal ('too many relations') solution I also saw was: Decompose R into R1(A,B,C,D) with local functional dependencies ABCD and CDAB, R2(A,B,F) with local functional dependencies ABF and R3(F,E) with local functional dependencies FA.. Problem 1; H1-2004: Problem 1; H1-2004 Candidate keys are: {a,b}, {a,d}, {a,e} 14 superkeys total All but the first functional dependency are bad Problem 2; H2-04: Problem 2; H2-04 No; EBC is a 'true' multi-valued dependency and E is not a candidate key (as a matter of fact {E}+={A,D,E,F} see below) No (but just mentioning neither E ABC nor E CF holds is not sufficient (e.g. if EABC holds then the decomposition is lossless!) ) --- a counter examples should be given to show that the statement is false! Yes C is candidate key; therefore CBDEF; therefore CBDEF Yes E BC and BC BCD implies ED due to MVD-transitivity (CCDBCBCD BCBCD) Yes EBC; therefore EADF; moreover, CADF and using the Coalescence Rule we obtain EADF; therefore, EA holds No R is not in BCNF because EADF holds and E is not a candidate key. Problem 3a-2004: Problem 3a-2004 From AB and AC we can infer: ABC?? (1) AC AAC (2) AB ACABC (3) ACABC ACDE (4) AAC, ACDE ADE (5) ADE ABC Using: 1. Augmentation, 2.Augmentation, 3.Complementation, 4.Transitivity, 5. Complementation Wrong!! Remark: This problem will be revised in Homework3-2005; it is too complicated to worry about it for the midterm exam! MDV’s and FD’s --- Ungraded Homework: MDV’s and FD’s --- Ungraded Homework Assume we have a relation R(A,B,C,D,E) with the following dependencies: (1) AB CDE (2) CD ABE (3) E DB Answer the following questions giving reasons for your answers: a) Is R in BCNF? ????? (answer after Spring break) Warning: The presence of the MVD might imply other functional dependencies (see textbook page 637) b) Does ABE D hold for R? yes c) Does CD B hold for R? yes d) Does E D always hold for R (either show that this dependency can be inferred from the given 3 dependencies, or give a counter example of a relation that satisfies (1), (2), (3) but violates ED)? No