Multivalued Dependency Prof. Sin-Min Lee Department of Computer Science.

Slides:



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

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.
ALAK ROY. Assistant Professor Dept. of CSE NIT Agartala N ATIONAL I NSTITUTE OF T ECHNOLOGY A GARTALA Aug-Dec,2010 Normalization 2 CSE-503 :: D ATABASE.
METU Department of Computer Eng Ceng 302 Introduction to DBMS Further Dependencies by Pinar Senkul resources: mostly froom Elmasri, Navathe and other books.
4NF and 5NF Prof. Sin-Min Lee Department of Computer Science.
1 Loss-Less Joins. 2 Decompositions uDependency-preservation property: enforce constraints on original relation by enforcing some constraints on resulting.
C.1 Appendix C: Advanced Relational Database Design Reasoning with MVDs Higher normal forms Join dependencies and PJNF DKNF.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Appendix B: Advanced.
4NF. PTypes Planes HasType Employees MServices Auth. MWorks Assignment AppliedOn States Dates PTypes(model, capacity,…) Planes(regno, model) Employees(sin,…)
Multivalued Dependency Prof. Sin-Min Lee Department of Computer Science.
1 Multi-valued Dependencies Salman Azhar Multi-valued Dependencies Fourth Normal Form These slides use some figures, definitions, and explanations from.
1 Multivalued Dependencies Fourth Normal Form Source: Slides by Jeffrey Ullman.
1 Multivalued Dependencies Fourth Normal Form. 2 Definition of MVD uA multivalued dependency (MVD) on R, X ->->Y, says that if two tuples of R agree on.
1 Multivalued Dependencies Fourth Normal Form Sources: Slides by Jeffrey Ullman book by Ramakrishnan & Gehrke.
CMSC424: Database Design Instructor: Amol Deshpande
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.
1 Multivalued Dependencies Fourth Normal Form. 2 A New Form of Redundancy uMultivalued dependencies (MVD’s) express a condition among tuples of a relation.
Fall 2001Arthur Keller – CS 1805–1 Schedule Today Oct. 9 (T) Multivalued Dependencies, Relational Algebra u Read Sections 3.7, Assignment 2 due.
Multivalued Dependency Tamer Abuelata. Introduction Goal in Databases: Goal in Databases: BCNF (Boyce Codd Normal Form) BCNF (Boyce Codd Normal Form)
1 Multi-valued Dependencies. 2 Multivalued Dependencies There are database schemas in BCNF that do not seem to be sufficiently normalized. Consider a.
MVDs: 1 Join Dependencies—Example Let r = A B C = A B |  | A C 1 a x 1 a 1 x 1 a y 1 b 1 y 1 b x 2 a 2 y 1 b y 2 b 2 a y 2 b y Observe: r =  AB r | 
Fall 2001Arthur Keller – CS 1804–1 Schedule Today Oct. 4 (TH) Functional Dependencies and Normalization. u Read Sections Project Part 1 due. Oct.
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.
FUNCTIONAL DEPENDENCIES
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.
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.
SCUJ. Holliday - coen 1784–1 Schedule Today: u Normal Forms. u Section 3.6. Next u Relational Algebra. Read chapter 5 to page 199 After that u SQL Queries.
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.
4NF (Multivalued Dependency), and 5NF (Join Dependency)
IST 210 Normalization 2 Todd Bacastow IST 210. Normalization Methods Inspection Closure Functional dependencies are key.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Appendix B: Advanced.
1 Multivalued Dependencies Fourth Normal Form Reasoning About FD’s + MVD’s.
1 Multivalued Dependencies Fourth Normal Form Reasoning About FD’s + MVD’s.
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.
Multivalued Dependencies and 4th NF CIS 4301 Lecture Notes Lecture /21/2006.
CS411 Database Systems Kazuhiro Minami 04: Relational Schema Design.
Databases 1 Sixth lecture. 2 Functional Dependencies X -> A is an assertion about a relation R that whenever two tuples of R agree on all the attributes.
© 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.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
4NF & MULTIVALUED DEPENDENCY By Kristina Miguel. Review  Superkey – a set of attributes which will uniquely identify each tuple in a relation  Candidate.
1 Database Design: DBS CB, 2 nd Edition Physical RDBMS Model: Schema Design and Normalization Ch. 3.
Schedule Today: Jan. 23 (wed) Week of Jan 28
3.1 Functional Dependencies
Relational Design Theory
CPSC-310 Database Systems
Module 5: Overview of Normalization
Chapter 7: Relational Database Design
Multivalued Dependencies & Fourth Normal Form (4NF)
Mulitvalued Dependencies
Multivalued Dependencies & Fourth Normal Form
Multivalued Dependencies & Fourth Normal Form
Appendix C: Advanced Normalization Theory
Relational Design Theory
Multivalued Dependencies
Appendix C: Advanced Relational Database Design
Chapter 28: Advanced Relational Database Design
Chapter 7a: Overview of Database Design -- Normalization
Presentation transcript:

Multivalued Dependency Prof. Sin-Min Lee Department of Computer Science

1NF 2NF 3NF BCNF 4NF 5NF functional dependencies multivalued dependencies join dependencies HIGHER NORMAL FORMS

Mary C++Reading Tennis Cycling Jenny C++Music Databases John PascalMusic DatabasesJogging Java STUDENTMODULEHOBBY STUDENT learns MODULE STUDENT enjoys HOBBY John learns Pascal Databases Java Mary learns C++ Jenny learns C++ Databases John enjoys Music Jogging Mary enjoys Reading Tennis Cycling Jenny enjoys Music

STUDENTMODULEHOBBY JohnPascalMusic JohnPascalJogging JohnDatabasesMusic JohnDatabasesJogging JohnJavaMusic JohnJavaJogging MaryC++Reading MaryC++Tennis MaryC++Cycling JennyC++Music JennyDatabasesMusic PROFILE multivalued dependency X  Y holds in R if: whenever two tuples of R agree in value of X, their image sets in  R(X,Y) are the same; X, Y, Z - pairwise disjoint subsets of R (X,Y,Z) STUDENT  MODULE STUDENT  HOBBY mutually independent PROFILE is in BCNF but exhibits redundancy and I, D ad U anomalies

Fourth Normal Form R(X, Y, Z) is in 4NF if, whenever a multivalued dependency X  Y holds for R, so does the functional dependency X  A for all attributes A in R preventing conjunction of unrelated facts 4NF: every MVD is FD

Multivalued Dependencies The multivalued dependency X  Y holds in a relation R if whenever we have two tuples of R that agree in all the attributes of X, then we can swap their Y components and get two new tuples that are also in R. X Y others

Example Drinkers(name, addr, phones, beersLiked) with MVD Name  phones. If Drinkers has the two tuples: nameaddrphonesbeersLiked sueap1b1 sueap2b2 it must also have the same tuples with phones components swapped: nameaddrphonesbeersLiked sueap2b1 sueap1b2 Note: we must check this condition for all pairs of tuples that agree on name, not just one pair.

MVD Rules 1.Every FD is an MVD. –Because if X  Y, then swapping Y’s between tuples that agree on X doesn’t create new tuples. –Example, in Drinkers : name  addr. 2.Complementation: if X  Y, then X  Z, where Z is all attributes not in X or Y. –Example: since name  phones holds in Drinkers, so does name  addr beersLiked.

Splitting Doesn’t Hold Sometimes you need to have several attributes on the right of an MVD. For example: Drinkers(name, areaCode, phones, beersLiked, beerManf) nameareaCodephonesbeersLikedbeerManf Sue BudA.B. Sue Wicked AlePete’s Sue BudA.B. Sue Wicked AlePete’s name  areaCode phones holds, but neither name  areaCode nor name  phones do.

4NF Eliminate redundancy due to multiplicative effect of MVD’s. Roughly: treat MVD’s as FD's for decomposition, but not for finding keys. Formally: R is in Fourth Normal Form if whenever MVD X  Y is nontrivial (Y is not a subset of X, and X  Y is not all attributes), then X is a superkey. –Remember, X  Y implies X  Y, so 4NF is more stringent than BCNF. Decompose R, using 4NF violation X  Y, into XY and X  (R—Y). R Y X

Example Drinkers(name, addr, phones, beersLiked) FD: name  addr Nontrivial MVD’s: name  phones and name  beersLiked. Only key: { name, phones, beersLiked } All three dependencies above violate 4NF. Successive decomposition yields 4NF relations: D1(name, addr) D2(name, phones) D3(name, beersLiked)

Multivalued Dependencies Multivalued dependencies are referred to as tuple- generating dependencies. Let R be a relation schema and let a  R and b  R. The multivalued dependency is a  b holds on R if, in any legal relation r( R ), for all pairs of tuples t1 and t2 in r such that t1[ a ] = t2[ a ], there exist tuples t3 and t4 in r such that

Multivalued Dependencies (cont) t1[ a ] = t2[ a ] = t3[ a ] = t4[ a ] t3[ b ] = t1[ b ] t3[ R - b ] = t2[ R - b ] t4[ b ] = t2[ b ] t4[ R - b ] = t1[ R - b ] The multivalued dependency a  b says that the relationship between a and b is independent of the relationship between a and R - b.

Multivalued Dependencies (cont) If the multivalued dependency a  b is satisfied by all relations on schema R, then a  b is a trivial multivalued dependency on schema R. Thus, a  b is trivial if b  a or b  a = R Tabular representation of a  b ab R - a - b t1a1…aiai+1…ajaj+1…an t2a1…aibi+1…bjbj+1…bn t3a1…aiai+1…ajbj+1…bn t4a1…aibi+1…bjaj+1…an

Example : Here is an example of multivalued dependencies given R(A B C D). Show that A  BD we can rearrange the table to R(A B D C). ABCD ABDC

Example (Cont.): Perform each test to check if A  BD. t 1 = r t 2 = r t 3 = r t 4 = r t 1 = r t 2 = r t 3 = r t 4 = r t 1 = r t 2 = r t 3 = r t 4 = r t 1 = r t 2 = r t 3 = r t 4 = r

Example (Cont.): Perform each test to check if A  BD. t 1 = r t 2 = r t 3 = r t 4 = r t 1 = r t 2 = r t 3 = r t 4 = r t 1 = r t 2 = r t 3 = r t 4 = r Each test is satisfied, so A  BD is true!!!

Multivalued Dependencies (cont) To illustrate the difference between functional and multivalued dependencies, we consider again the BC- schema. Graph 1 loan-numbercustomer-namecustomer-streetcustomer-city L-23SmithNorthRye L-23SmithMainManchester L-93CurryLakeHorseneck

Multivalued Dependencies (cont) On graph 1, we must repeat the loan number once for each address a customer has, and we must repeat the address for each loan a customer has. This repetition is unnecessary, since the relationship between that customer and his address is independent of the relationship between that customer and a loan. If a customer (say, Smith) has a loan (say, loan number L- 23), we want that loan to be associated with all Smith’s addresses.

Multivalued Dependencies (cont) The relation on graph 2 is illegal, therefore to make this relation legal, we need to add the tuples (L-23, Smith, Main, Manchester) and (L-27, Smith, North, Rye) to the bc relation of graph 2. Graph 2 (an illegal bc relation) loan-numbercustomer-namecustomer-streetcustomer-city L-23SmithNorthRye L-27SmithMainManchester

Multivalued Dependencies (cont) Comparing the preceding example with our definition of multivalued dependency, we see that we want the multivalued dependency to hold. customer-name  customer-street customer-city As was the case for functional dependencies, we shall use multivalued dependencies in two ways: 1. To test relations to determine whether they are legal under a given set of functional and multivalued dependencies. 2. To specify constraints on the set of legal relations; we shall thus concern ourselves with only those relations that specify a given set of functional and multivalued dependencies.

Theory of Multivalued Dependencies 1.Reflexivity rule. If a is a set attributes, and b C a, then a  b holds. 2.Augmentation rule. If a  b holds, and c is a set of attributes, then ca  cb holds. 3.Transitivity rule. If a  b holds, and b  c holds, then a  c holds. 4.Complementation rule. If a  b holds, then a  R – b – a holds.

Theory of Multivalued Dependencies 5. Multivalued augmentation rule. If a  b holds, and c R and d C c, then ca  db holds. 6. Multivalued transitivity rule. If a  b holds, and b  c holds, then a  c – b holds. 7. Replication rule. If a  b holds, then a  b. 8. Coalescence rule. If a  b holds, and c C b, and there is a d such that d C R, and d 3 b = w, and d  c, then a  c holds.

Theory of Multivalued Dependencies (cont) 1.Multivalued union rule. If a  b holds, and a  c holds, then a  bc holds. 2.Intersection rule. If a  b holds, and a  c holds, then a  b 3 c holds. 3.Difference rule. If a  b holds, and a  c holds, then a  b - c holds and a  c - b holds.