Multivalued Dependencies By David Wortham. Problem Introduction Assume a relation R (from the book): (credit Ullman and Widom) Assume a relation R (from.

Slides:



Advertisements
Similar presentations
Higher Normal Forms By John Nicosia CS 157a Fall 2007.
Advertisements

Functional Dependencies (FDs)
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
METU Department of Computer Eng Ceng 302 Introduction to DBMS Further Dependencies by Pinar Senkul resources: mostly froom Elmasri, Navathe and other books.
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.
Relational Normalization Theory. Limitations of E-R Designs Provides a set of guidelines, does not result in a unique database schema Does not provide.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 8 A First Course in Database Systems.
Multivalued Dependency Prof. Sin-Min Lee Department of Computer Science.
1 Multivalued Dependencies Fourth Normal Form Source: Slides by Jeffrey Ullman.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Relational Database Design - part 2 - Database Management Systems I Alex Coman,
Multivalued Dependency Prof. Sin-Min Lee Department of Computer Science.
Functional Dependencies (Part 3) Presented by Nash Raghavan All page numbers are in reference to Database System Concepts (5 th Edition)
1 CMSC424, Spring 2005 CMSC424: Database Design Lecture 9.
Winter 2002Arthur Keller – CS 1804–1 Schedule Today: Jan. 15 (T) u Normal Forms, Multivalued Dependencies. u Read Sections Assignment 1 due. Jan.
Multivalued Dependencies by Asmerom Tekeste. Normal Forms 1NF 2NF 3NF BCNF 4NF 5NF Functional dependencies Multivalued dependencies Join dependencies.
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.
4 TH NORMAL FORM By: Karen McVay. REVIEW OF NFs 1NF  All values of the columns are atomic. That is, they contain no repeating values. 1NF  All values.
1 Triggers: Correction. 2 Mutating Tables (Explanation) The problems with mutating tables are mainly with FOR EACH ROW triggers STATEMENT triggers can.
Normalization II. Boyce–Codd Normal Form (BCNF) Based on functional dependencies that take into account all candidate keys in a relation, however BCNF.
Chapter 14 Advanced Normalization Transparencies © Pearson Education Limited 1995, 2005.
Chapter 11 Relational Database Design Algorithms and Further Dependencies Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Computing & Information Sciences Kansas State University Monday, 13 Oct 2008CIS 560: Database System Concepts Lecture 18 of 42 Monday, 13 October 2008.
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.
Multi-valued Dependencies and Fourth Normal Form
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.
Relational Database Design by Relational Database Design by Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING.
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.
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.
Computing & Information Sciences Kansas State University Wednesday, 04 Oct 2006CIS 560: Database System Concepts Lecture 17 of 42 Wednesday, 04 October.
Relational Database Design Algorithms and Further Dependencies.
Chapter 11: Relational Database Design Algorithms and Further Dependencies Chapter 11: Relational Database Design Algorithms and Further Dependencies 1.
CS 564 Database Management Systems: Design and Implementation Discussion Session Friday, Sept 18, Apul Jain.
Functional Dependencies. FarkasCSCE 5202 Reading and Exercises Database Systems- The Complete Book: Chapter 3.1, 3.2, 3.3., 3.4 Following lecture slides.
1 Lecture 7: Normal Forms, Relational Algebra Monday, 10/15/2001.
© D. Wong Ch. 3 (continued)  Database design problems  Functional Dependency  Keys of relations  Decompositions based on Functional Dependency.
Design Process - Where are we?
© D. Wong Normalization  Purpose: process to eliminate redundancy in relations due to functional or multi-valued dependencies.  Decompose relation.
1 Multivalued Dependencies Fourth Normal Form Reasoning About FD’s + MVD’s.
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.
© 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.
Final Review Zaki Malik November 20, Basic Operators Covered.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
1 CS 430 Database Theory Winter 2005 Lecture 8: Functional Dependencies Second, Third, and Boyce-Codd Normal Forms.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts.
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.
4TH NORMAL FORM By: Karen McVay.
Chapter 15 Relational Design Algorithms and Further Dependencies
Relational Database Design by Dr. S. Sridhar, Ph. D
3.1 Functional Dependencies
Chapter 7: Relational Database Design
Mulitvalued Dependencies
Multivalued Dependencies & Fourth Normal Form
Multivalued Dependencies
Presentation transcript:

Multivalued Dependencies By David Wortham

Problem Introduction Assume a relation R (from the book): (credit Ullman and Widom) Assume a relation R (from the book): (credit Ullman and Widom) NameAddrStreetAddrCityFilmNameFilmYear C. Fisher 123 Maple Dr. Hollywood Star Wars 1977 C. Fisher 5 Locust Ln. Malibu Star Wars 1977 C. Fisher 123 Maple Dr. Hollywood The Empire Strikes Back 1980 C. Fisher 5 Locust Ln. Malibu The Empire Strikes Back 1980 C. Fisher 123 Maple Dr. Hollywood Return of the Jedi 1983 C. Fisher 5 Locust Ln. Malibu Return of the Jedi 1983 Carrie Fisher = Princess Leia Organa

Problem Introduction What is the highest Normal Form R complies with? What is the highest Normal Form R complies with? NameAddrStreetAddrCityFilmNameFilmYear C. Fisher 123 Maple Dr. Hollywood Star Wars 1977 C. Fisher 5 Locust Ln. Malibu Star Wars 1977 C. Fisher 123 Maple Dr. Hollywood The Empire Strikes Back 1980 C. Fisher 5 Locust Ln. Malibu The Empire Strikes Back 1980 C. Fisher 123 Maple Dr. Hollywood Return of the Jedi 1983 C. Fisher 5 Locust Ln. Malibu Return of the Jedi 1983

Recall 1NF 1NF eliminates wasted space due to duplicate attributes (columns) 1NF eliminates wasted space due to duplicate attributes (columns) Example (before 1NF normalization): Example (before 1NF normalization): Manager Subordinate 1 Subordinate 2 Subordinate 3 Subordinate 4 BobJimMaryBeth MaryMikeJasonCarolMark JimAlan

Recall 1NF (con’t) After 1NF normalization: After 1NF normalization: ManagerSubordinate BobJim BobMary BobBeth MaryMike MaryJason MaryCarol MaryMark JimAlan

Identify the FDs Functional Dependencies in R: Functional Dependencies in R: Since every tuple in R is unique, the Since every tuple in R is unique, the attrAattrBattrCattrDattrE

Identify the FDs Functional Dependencies in R: Functional Dependencies in R: The only FD is: {attrB, attrC, attrD, attrE }  attrA The only FD is: {attrB, attrC, attrD, attrE }  attrA attrAattrBattrCattrDattrE

Identify the FDs Functional Dependencies in R: Functional Dependencies in R: attrAattrBattrCattrDattrE

Identify the FDs Functional Dependencies in R: Functional Dependencies in R: attrAattrBattrCattrDattrE

Normal Form of R 1NF (no multivalues) [check] 1NF (no multivalues) [check] 2NF (no FDs where a subset of the key to the relation is on the left) [check] 2NF (no FDs where a subset of the key to the relation is on the left) [check] 3NF (no non-trivial FDs: either the determinant is a superkey or the RHS of the FD is a member of some key) [check] 3NF (no non-trivial FDs: either the determinant is a superkey or the RHS of the FD is a member of some key) [check] BCNF (the determnant of any non-trivial FD is a superkey for the relation) [check] BCNF (the determnant of any non-trivial FD is a superkey for the relation) [check]

Problem Intro. (con’t) Notice: Notice: NameAddrStreetAddrCityFilmNameFilmYear C. Fisher 123 Maple Dr. Hollywood Star Wars 1977 C. Fisher 5 Locust Ln. Malibu Star Wars 1977 C. Fisher 123 Maple Dr. Hollywood The Empire Strikes Back 1980 C. Fisher 5 Locust Ln. Malibu The Empire Strikes Back 1980 C. Fisher 123 Maple Dr. Hollywood Return of the Jedi 1983 C. Fisher 5 Locust Ln. Malibu Return of the Jedi 1983

Problem Intro. (con’t) Also Notice: Also Notice: NameAddrStreetAddrCityFilmNameFilmYear C. Fisher 123 Maple Dr. Hollywood Star Wars 1977 C. Fisher 5 Locust Ln. Malibu Star Wars 1977 C. Fisher 123 Maple Dr. Hollywood The Empire Strikes Back 1980 C. Fisher 5 Locust Ln. Malibu The Empire Strikes Back 1980 C. Fisher 123 Maple Dr. Hollywood Return of the Jedi 1983 C. Fisher 5 Locust Ln. Malibu Return of the Jedi 1983

Observe the Pattern R ~= TxUxV (R is similar to the Cartesian product of relations T, U, and V) R ~= TxUxV (R is similar to the Cartesian product of relations T, U, and V) AddrStreetAndCity 123 Maple Dr. | Hollywood 5 Locust Ln. | Malibu FilmNameAndYear Star Wars | 1977 The Empire Strikes Back | 1980 Return of the Jedi | 1983 Name C. Fisher Relation TRelation URelation V

Problem Definition The Relation R contains unnecessary duplication of data The Relation R contains unnecessary duplication of data R is valid 1NF, 2NF, 3NF, and BCNF (and there are no exact duplicate tuples) R is valid 1NF, 2NF, 3NF, and BCNF (and there are no exact duplicate tuples) R has common data on AddrStreet and AddrCity of all tuples R has common data on AddrStreet and AddrCity of all tuples R has common data on FilmName and FilmLocat of all tuples R has common data on FilmName and FilmLocat of all tuples

Solution Introduction of a 4NF Introduction of a 4NF Eliminate “non-trivial” MDs Eliminate “non-trivial” MDs Eliminate additional FDs that violate BCNF Eliminate additional FDs that violate BCNF

Definitions Fourth Normal Form - if R is valid BCNF and… - given the “non-trivial” MVD: A 1 A 2 …A n  B 1 B 2 …B n {A 1 A 2 …A n } is a superkey Fourth Normal Form - if R is valid BCNF and… - given the “non-trivial” MVD: A 1 A 2 …A n  B 1 B 2 …B n {A 1 A 2 …A n } is a superkey A MVD: A 1 A 2 …A n  B 1 B 2 …B n for a Relation R is “non-trivial” if: 1.none of the Bs are among the As 2.Not all of the attributes of R are among the As and Bs A MVD: A 1 A 2 …A n  B 1 B 2 …B n for a Relation R is “non-trivial” if: 1.none of the Bs are among the As 2.Not all of the attributes of R are among the As and Bs A MVD is “trivial” if it contains all the variations of A 1 A 2 …A n x B 1 B 2 …B n. A MVD is “trivial” if it contains all the variations of A 1 A 2 …A n x B 1 B 2 …B n. A relation cannot be decomposed any further (under 4NF rules) if it has a trivial MVD A relation cannot be decomposed any further (under 4NF rules) if it has a trivial MVD

Recall our Problem Relation Recall our BCNF Relation R: Recall our BCNF Relation R: NameAddrStreetAddrCityFilmNameFilmYear C. Fisher 123 Maple Dr. Hollywood Star Wars 1977 C. Fisher 5 Locust Ln. Malibu Star Wars 1977 C. Fisher 123 Maple Dr. Hollywood The Empire Strikes Back 1980 C. Fisher 5 Locust Ln. Malibu The Empire Strikes Back 1980 C. Fisher 123 Maple Dr. Hollywood Return of the Jedi 1983 C. Fisher 5 Locust Ln. Malibu Return of the Jedi 1983

Note about FDs and MVDs Every FD is a MVD Every FD is a MVD (if A 1 A 2 …A n  B 1 B 2 …B n, then A 1 A 2 …A n  B 1 B 2 …B n ) The converse is not always true The converse is not always true FDs rule out certain tuples (i.e. if A  B then two tuples will not have the same value for A and different values for B) FDs rule out certain tuples (i.e. if A  B then two tuples will not have the same value for A and different values for B) MVDs do not rule out tuples. They guarantee that certain tuples must exist. (we will see this later) MVDs do not rule out tuples. They guarantee that certain tuples must exist. (we will see this later)

Another Example Another MVD example (credit Another MVD example (credit emp_namequalificationslanguages SMITH B. Sc NULL SMITH Dip. CS NULL SMITHNULLFORTRAN SMITHNULLCOBOL SMITHNULLPASCAL

Another Example (con’t) Our second example 4NF decomposed: Our second example 4NF decomposed: emp_namequalificationslanguages SMITH B. Sc NULL SMITH Dip. CS NULL SMITHNULLFORTRAN SMITHNULLCOBOL SMITHNULLPASCAL emp_namequalificationsSMITH B. Sc SMITH Dip. CS emp_namelanguagesSMITHFORTRAN SMITHCOBOL SMITHPASCAL Relation L Relation M Relation O

Explanation of second example Unnecessary tuples are eliminated (those with NULL values)… saving space Unnecessary tuples are eliminated (those with NULL values)… saving space Note: for this example, MxO is not similar to L: this is because the MVD in L is non- trivial Note: for this example, MxO is not similar to L: this is because the MVD in L is non- trivial

Second example (modified) If we were to modify the second example L to be 4NF, we would need to combine every possible value of M with every one of O, changing the MVD from non-trivial to trivial If we were to modify the second example L to be 4NF, we would need to combine every possible value of M with every one of O, changing the MVD from non-trivial to trivial This relation would look similar to the product of M and O This relation would look similar to the product of M and O

Second example (modified) If we were to modify the second example L, we would need to combine every possible value of M with every one of O If we were to modify the second example L, we would need to combine every possible value of M with every one of O emp_namequalificationslanguages SMITH B. Sc NULL SMITH Dip. CS NULL SMITHNULLFORTRAN SMITHNULLCOBOL SMITHNULLPASCAL Relation L

Second example (modified) If we were to modify the second example L, we would need to combine every possible value of M with every one of O If we were to modify the second example L, we would need to combine every possible value of M with every one of O This relation is 4NF b/c the only MVD is trivial (the original L was not 4NF) This relation is 4NF b/c the only MVD is trivial (the original L was not 4NF) emp_namequalificationslanguages SMITH B. Sc FORTRAN SMITH Dip. CS FORTRAN SMITH B. Sc COBOL SMITH Dip. CS COBOL SMITH B. Sc PASCAL SMITH Dip. CS PASCAL Relation L w/ Trivial MVD

Formal Definition of a MVD Using the following relation, (credit Ullman & Widom) Using the following relation, (credit Ullman & Widom) Note that A, B, and “others” are not actual attributes, but rather sets of attributes Note that A, B, and “others” are not actual attributes, but rather sets of attributes AsBsothers tuple t a1a1a1a1 b1b1b1b1 c1c1c1c1 == tuple u a1a1a1a1 b1b1b1b1 c2c2c2c2 == tuple v a1a1a1a1 b2b2b2b2 c2c2c2c2

Formal Definition of a MVD (con’t) Suppose A  B holds, then: Suppose A  B holds, then: t[A] = u[A] = v[A] t[A] = u[A] = v[A] t[B] = u[B] t[B] = u[B] u[C] = v[C] u[C] = v[C] If a MVD is to exist, u must exist. If a MVD is to exist, u must exist. For the MVD to be non-trivial, every tuple must be in the form of a u tuple For the MVD to be non-trivial, every tuple must be in the form of a u tuple AsBsothers tuple t a1a1a1a1 b1b1b1b1 c1c1c1c1 == tuple u a1a1a1a1 b1b1b1b1 c2c2c2c2 == tuple v a1a1a1a1 b2b2b2b2 c2c2c2c2

Formal Definition of a MVD (con’t) For the MVD A  B to be trivial, either: For the MVD A  B to be trivial, either: B  A or B  A or B  A = R B  A = R Must be true AsBsothers tuple t a1a1a1a1 b1b1b1b1 c1c1c1c1 == tuple u a1a1a1a1 b1b1b1b1 c2c2c2c2 == tuple v a1a1a1a1 b2b2b2b2 c2c2c2c2

Armstrong’s Axioms WRT MVDs Many of Armstrong’s Axioms work with MVDs including: Many of Armstrong’s Axioms work with MVDs including: Reflexivity rule Reflexivity rule Augmentation rule Augmentation rule Transitivity rule Transitivity rule Complementation rule Complementation rule Multivalued augmentation rule Multivalued augmentation rule Multivalued transitivity rule Multivalued transitivity rule Replication rule Replication rule Coalescence rule Coalescence rule Multivalued union rule Multivalued union rule Intersection rule Intersection rule Difference rule Difference rule See below for specifics on these rules See below for specifics on these rules

References Course textbook: a First Course in Database Systems (Jeffrey D. Ullman and Jennifer Widom) Course textbook: a First Course in Database Systems (Jeffrey D. Ullman and Jennifer Widom) Normalizing your database: First Normal Form (1NF): Normalizing your database: First Normal Form (1NF): Multivalued Dependencies (Ozmar Zaine): Multivalued Dependencies (Ozmar Zaine): Multivalued Dependencies: Multivalued Dependencies: