Multi-valued Dependencies and Fourth Normal Form

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Schema Refinement: Canonical/minimal Covers
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Lecture 21 CS 157 B Revision of Midterm3 Prof. Sin-Min Lee.
Normalization Decomposition techniques for ensuring: Lossless joins Dependency preservation Redundancy avoidance We will look at some normal forms: Boyce-Codd.
Logical Database Design (3 of 3) John Ortiz. Lecture 7Logical Database Design (2)2 Normalization  If a relation is not in BCNF or 3NF, we refine it by.
METU Department of Computer Eng Ceng 302 Introduction to DBMS Further Dependencies by Pinar Senkul resources: mostly froom Elmasri, Navathe and other books.
1 Design Theory. 2 Minimal Sets of Dependancies A set of dependencies is minimal if: 1.Every right side is a single attribute 2.For no X  A in F and.
Chapter 3 Notes. 3.1 Functional Dependencies A functional dependency is a statement that – two tuples of a relation that agree on some particular set.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 227 Database Systems I Design Theory for Relational Databases.
Normalization DB Tuning CS186 Final Review Session.
Normalization DB Tuning CS186 Final Review Session.
FDImplication: 1 Functional Dependencies (FDs) Let r(R) be a relation and let t  r, then the restriction of t to X  R, written t[X], is the projection.
Closure The closure of {B 1 …B k } under the set of FDs S, denoted by {B 1 …B k } +, is defined as follows: {B 1 …B k } + = {B | any relation satisfies.
CMSC424: Database Design Instructor: Amol Deshpande
Nov 11, 2003Murali Mani Normalization B term 2004: lecture 7, 8, 9.
The principal problem that we encounter is redundancy, where a fact is repeated in more than one tuple. Most common cause: attempts to group into one relation.
1 CMSC424, Spring 2005 CMSC424: Database Design Lecture 9.
Decomposition By Yuhung Chen CS157A Section 2 October
Multivalued Dependencies by Asmerom Tekeste. Normal Forms 1NF 2NF 3NF BCNF 4NF 5NF Functional dependencies Multivalued dependencies Join dependencies.
Multivalued Dependencies By David Wortham. Problem Introduction Assume a relation R (from the book): (credit Ullman and Widom) Assume a relation R (from.
Multivalued Dependencies. Intuition Redundancy: addresses, title repeated several times –because a star might have several addresses and stars in several.
1 Multi-valued Dependencies. 2 Multivalued Dependencies There are database schemas in BCNF that do not seem to be sufficiently normalized. Consider a.
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
Fall 2001Arthur Keller – CS 1804–1 Schedule Today Oct. 4 (TH) Functional Dependencies and Normalization. u Read Sections Project Part 1 due. Oct.
1 Triggers: Correction. 2 Mutating Tables (Explanation) The problems with mutating tables are mainly with FOR EACH ROW triggers STATEMENT triggers can.
Chapter 14 Advanced Normalization Transparencies © Pearson Education Limited 1995, 2005.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Database Systems Normal Forms. Decomposition Suppose we have a relation R[U] with a schema U={A 1,…,A n } – A decomposition of U is a set of schemas.
Normalization Goal = BCNF = Boyce-Codd Normal Form = all FD’s follow from the fact “key  everything.” Formally, R is in BCNF if for every nontrivial FD.
Copyright © Curt Hill Schema Refinement III 4 th NF and 5 th NF.
Chapter 8: Relational Database Design First Normal Form First Normal Form Functional Dependencies Functional Dependencies Decomposition Decomposition Boyce-Codd.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
CS143 Review: Normalization Theory Q: Is it a good table design? We can start with an ER diagram or with a large relation that contain a sample of the.
Functional Dependencies An example: loan-info= Observe: tuples with the same value for lno will always have the same value for amt We write: lno  amt.
THIRD NORMAL FORM (3NF) A relation R is in BCNF if whenever a FD XA holds in R, one of the following statements is true: XA is a trivial FD, or X is.
BCNF & Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science.
Computing & Information Sciences Kansas State University Tuesday, 27 Feb 2007CIS 560: Database System Concepts Lecture 18 of 42 Tuesday, 27 February 2007.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 11 Relational Database Design Algorithms and Further Dependencies.
Revisit FDs & BCNF Normalization 1 Instructor: Mohamed Eltabakh
Functional Dependencies. FarkasCSCE 5202 Reading and Exercises Database Systems- The Complete Book: Chapter 3.1, 3.2, 3.3., 3.4 Following lecture slides.
Christoph F. Eick: Functional Dependencies, BCNF, and Normalization 1 Functional Dependencies, BCNF and Normalization.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Normalization.
1 Multivalued Dependencies Fourth Normal Form Reasoning About FD’s + MVD’s.
1 Multivalued Dependencies Fourth Normal Form Reasoning About FD’s + MVD’s.
Design Theory for RDB Normal Forms. Lu Chaojun, SJTU 2 Redundant because these info may be figured out by using FD s1  … What’s Bad Design? Redundancy.
3 Spring Chapter Normalization of Database Tables.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Multivalued Dependencies Fourth Normal Form Tony Palladino 157B.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.
Multivalued Dependencies and 4th NF CIS 4301 Lecture Notes Lecture /21/2006.
Lecture 17 4 th Normal Form Prof. Sin-Min Lee Department of Computer Science.
CS542 1 Schema Refinement Chapter 19 (part 1) Functional Dependencies.
© D. Wong Functional Dependencies (FD)  Given: relation schema R(A1, …, An), and X and Y be subsets of (A1, … An). FD : X  Y means X functionally.
Relational Database Design Algorithms and Further Dependencies.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
Normal Forms Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems June 18, 2016 Some slide content courtesy of Susan Davidson.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
4NF & MULTIVALUED DEPENDENCY By Kristina Miguel. Review  Superkey – a set of attributes which will uniquely identify each tuple in a relation  Candidate.
More on Decompositions and Third Normal Form CIS 4301 Lecture Notes Lecture /16/2006.
Advanced Normalization
3.1 Functional Dependencies
Advanced Normalization
Mulitvalued Dependencies
Multivalued Dependencies
Presentation transcript:

Multi-valued Dependencies and Fourth Normal Form COSC 6340

Topics Covered Definition of Multivalued Dependencies Reasoning about MVDs Fourth Normal Form Ch. Eick: 4thNF and MVD's

Motivation There are schemas that are in BCNF that do not seem to be sufficiently normalized Stars name street city title year C. Fisher 123 Maple Str. Hollywood Star Wars 1977 C. Fisher 5 Locust Ln. Malibu Star Wars 1977 C. Fisher 123 Maple Str. Hollywood Empire Strikes Back 1980 C. Fisher 5 Locust Ln. Malibu Empire Strikes Back 1980 C. Fisher 123 Maple Str. Hollywood Return of the Jedi 1983 C. Fisher 5 Locust Ln. Malibu Return of the Jedi 1983 Ch. Eick: 4thNF and MVD's

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? Ch. Eick: 4thNF and MVD's

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) Ch. Eick: 4thNF and MVD's

Pictorially Speaking... An MVD guarantees v exists A’s B’s Others t v w An MVD guarantees v exists The existence of a fourth tuple w is implied by interchanging t and u Ch. Eick: 4thNF and MVD's

Example: name  street city Stars name street city title year C. Fisher 123 Maple Str. Hollywood Star Wars 1977 t C. Fisher 5 Locust Ln. 123 Maple Str. Malibu Hollywood Star Wars 1977 Return of the Jedi 1983 v C. Fisher 123 Maple Str. Hollywood Empire Strikes Back 1980 u C. Fisher 5 Locust Ln. Malibu Empire Strikes Back 1980 Ch. Eick: 4thNF and MVD's

Example: name  street city Stars name street city title year C. Fisher 123 Maple Str. Hollywood Star Wars 1977 u C. Fisher 5 Locust Ln. Malibu Star Wars 1977 w v C. Fisher 123 Maple Str. Hollywood Empire Strikes Back 1980 t C. Fisher 5 Locust Ln. Malibu Empire Strikes Back 1980 C. Fisher 123 Maple Str. 5 Locust Ln. Hollywood Malibu Return of the Jedi 1983 Ch. Eick: 4thNF and MVD's

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 Ch. Eick: 4thNF and MVD's

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 123 Maple Str. Hollywood Star Wars 1977 C. Fisher 5 Locust Ln. Malibu Empire Strikes Back 1980 C. Fisher 123 Maple Str. Hollywood Return of the Jedi 1983 Is an incomplete extent of Stars Infer the existence of a fourth tuple under the given MVD Ch. Eick: 4thNF and MVD's

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 Ch. Eick: 4thNF and MVD's

Reasoning About MVDs FD-IS-AN-MVD Rule (Replication) If A1A2…An  B1B2…Bm then A1A2…An  B1B2…Bm holds Ch. Eick: 4thNF and MVD's

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 XY and WZ then WX YZ TRANSITIVITY Rule If XY and YZ then X  (Z-Y) Ch. Eick: 4thNF and MVD's

Coalescence Rule for MVD X  Y Then: X  Z If:   W:W  Z Remark: Y and W have to be disjoint and Z has to be a subset of or equal to Y Ch. Eick: 4thNF and MVD's

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…AnB1B2…Bm , A1A2…An is a superkey Note: Since every FD is also an MVD, 4NF implies BCNF Example: Stars is not in 4NF Ch. Eick: 4thNF and MVD's

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 ->> 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! Ch. Eick: 4thNF and MVD's

Exercise Decompose Stars into a set of relations that are in 4NF. namestreet city is a 4NF violation Apply decomposition: R(name, street, city) S(name, title, year) What about namestreet city in R and nametitle year in S? Ch. Eick: 4thNF and MVD's

Exercise For the relation R(A,B,C,D) with only MVD’s AB and AC find all 4NF violations and decompose R into a collection of relation schemas in 4NF. Ch. Eick: 4thNF and MVD's

Solution Since there are no functional dependencies, the only key is all four attributes, ABCD. Thus, each of the nontrivial multivalued dependencies A->->B and A->->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->->C is still a 4NF violation for ACD. The final set of relations are AB, AC, and AD. Ch. Eick: 4thNF and MVD's

Exercise Suppose we have relation R(A,B,C) with MVD AB. 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? Ch. Eick: 4thNF and MVD's

Solution Since A->->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. Ch. Eick: 4thNF and MVD's

Another View of 4NF True MVD’s MVD’s that are also ‘s FD’s Trivial True MVD XY:= non-trivial & XY does not hold ‘s True MVD’s MVD’s that are also FD’s Remark: If XY is a true MVD then X cannot be a superkey (because XY does not hold); Therefore, true MVD’s always violate 4NF (“true MVD’s are always bad) Trivial MVD’s 4NF:= Relation is in BCNF and there are no true MVD’s (yellow part is empty) XY and XY XY and not XY XY Ch. Eick: 4thNF and MVD's

H1-2005-Problem8 8) Normalization [6] graded R(A,B,C,D,E,F) is given with: (1) ABCD (2)CDAB (3)ABF (4) FE 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 ABCD and CDAB, R2(A,B,F) with local functional dependencies ABF and R3(F,E) with local functional dependencies FA.. Ch. Eick: 4thNF and MVD's

Problem 1; H1-2004 Candidate keys are: {a,b}, {a,d}, {a,e} 14 superkeys total All but the first functional dependency are bad Ch. Eick: 4thNF and MVD's

Problem 2; H2-04 No; EBC 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 EABC 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 CBDEF; therefore CBDEF Yes E BC and BC BCD implies ED due to MVD-transitivity (CCDBCBCD  BCBCD) Yes EBC; therefore EADF; moreover, CADF and using the Coalescence Rule we obtain EADF; therefore, EA holds No R is not in BCNF because EADF holds and E is not a candidate key. Ch. Eick: 4thNF and MVD's

Problem 3a-2004 From AB and AC we can infer: ABC?? (1) AC AAC (2) AB  ACABC (3) ACABC  ACDE (4) AAC, ACDE ADE (5) ADE ABC 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! Ch. Eick: 4thNF and MVD's

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 ED)? No Ch. Eick: 4thNF and MVD's