Multivalued Dependencies and 4th NF CIS 4301 Lecture Notes Lecture 12 - 2/21/2006.

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.
Spring 2011 Instructor: Hassan Khosravi
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.
Database Management COP4540, SCS, FIU Functional Dependencies (Chapter 14)
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 6 A First Course in Database Systems.
C.1 Appendix C: Advanced Relational Database Design Reasoning with MVDs Higher normal forms Join dependencies and PJNF DKNF.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 227 Database Systems I Design Theory for Relational Databases.
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.
Classroom Exercise: Normalization
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.
Functional Dependencies Definition: If two tuples agree on the attributes A, A, … A 12n then they must also agree on the attributes B, B, … B 12m Formally:
Nov 11, 2003Murali Mani Normalization B term 2004: lecture 7, 8, 9.
Multivalued Dependency Prof. Sin-Min Lee Department of Computer Science.
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.
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.
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.
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.
Ch 7: Normalization-Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
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.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Further Normalization II: Higher Normal Forms Prof. Yin-Fu Huang CSIE, NYUST Chapter 13.
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.
Lecture 09: Functional Dependencies. Outline Functional dependencies (3.4) Rules about FDs (3.5) Design of a Relational schema (3.6)
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.
Computing & Information Sciences Kansas State University Tuesday, 27 Feb 2007CIS 560: Database System Concepts Lecture 18 of 42 Tuesday, 27 February 2007.
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.
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.
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.
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/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.
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.
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
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
Relational Design Theory
Multivalued Dependencies & Fourth Normal Form (4NF)
Mulitvalued Dependencies
Relational Design Theory
Multivalued Dependencies
Presentation transcript:

Multivalued Dependencies and 4th NF CIS 4301 Lecture Notes Lecture /21/2006

Lecture 11© CIS Spring Multivalued Dependencies There are schemas that are in BCNF that do not seem to be sufficiently normalized namestreet Stars citytitleyear 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 Wars1977 Star Wars1977 Empire Strikes Back1980 Empire Strikes Back1980 Return of the Jedi1983 Return of the Jedi1983

Lecture 11© CIS Spring 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?

Lecture 11© CIS Spring Definition Definition: Multivalued dependency (MVD): A 1 A 2 …A n  B 1 B 2 …B m holds for relation R if: For all tuples t, u in R If t[A 1 A 2...A n ] = u[A 1 A 2...A n ], then there exists a v in R such that: (1) v[A 1 A 2...A n ] = t[A 1 A 2...A n ] = u[A 1 A 2...A n ] (2) v[B 1 B 2 …B m ] = t[B 1 B 2 …B m ] (3) v[C 1 C 2 …C k ] = u[C 1 C 2 …C k ], where C 1 C 2 …C k is all attributes in R except (A 1 A 2...A n  B 1 B 2 …B m )

Lecture 11© CIS Spring Pictorially Speaking... An MVD guarantees v exists The existence of a fourth tuple w is implied by interchanging t and u t u A’sB’sOthers v w

Lecture 11© CIS Spring Example: name  street city namestreet Stars citytitleyear C. Fisher 123 Maple Str. 5 Locust Ln. Hollywood Malibu Star Wars1977 Empire Strikes Back1980 Empire Strikes Back1980 C. Fisher 5 Locust Ln. 123 Maple Str. 5 Locust Ln.C. Fisher Malibu Hollywood Malibu Star Wars1977 Return of the Jedi1983 Return of the Jedi1983 t u v

Lecture 11© CIS Spring Example: name  street city namestreet Stars citytitleyear C. Fisher 123 Maple Str. 5 Locust Ln. 123 Maple Str. 5 Locust Ln. Hollywood Malibu Hollywood Malibu Star Wars1977 Star Wars1977 Empire Strikes Back1980 Empire Strikes Back1980 C. Fisher123 Maple Str. 5 Locust Ln.C. Fisher Hollywood Malibu Return of the Jedi1983 Return of the Jedi1983 u t w v

Lecture 11© CIS Spring More on MVDs Intuitively, A 1 A 2 …A n  B 1 B 2 …B m says that the relationship between A 1 A 2 …A n and B 1 B 2 …B m is independent of the relationship between A 1 A 2 …A n and R -{B 1 B 2 …B m } 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

Lecture 11© CIS Spring 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 namestreetcitytitleyear C. Fisher 123 Maple Str. 5 Locust Ln. 123 Maple Str. Hollywood Malibu Hollywood Star Wars1977 Empire Strikes Back1980 Return of the Jedi1983 Is an incomplete extent of Stars Infer the existence of a fourth tuple under the given MVD

Lecture 11© CIS Spring Trivial MVDs Trivial MVD A 1 A 2 …A n  B 1 B 2 …B m where B 1 B 2 …B m is a subset of A 1 A 2 …A n or (A 1 A 2 …A n  B 1 B 2 …B m ) contains all attributes of R

Lecture 11© CIS Spring Reasoning About MVDs FD-IS-AN-MVD Rule If A 1 A 2 …A n  B 1 B 2 …B m then A 1 A 2 …A n  B 1 B 2 …B m holds Prove by showing (1), (2), (3) in MVD definition Let A 1 A 2 …A n  B 1 B 2 …B m hold on R. Suppose t, u are tuples of R that agree on A 1 A 2 …A n. Need to show that R also contains tuple v that agrees with t and u on A’s, with t on B’s, and with u on all other attributes. Let v be u. 

Lecture 11© CIS Spring Reasoning About MVDs TRANSITIVE Rule If A 1 A 2 …A n  B 1 B 2 …B m and B 1 B 2 …B m  C 1 C 2 …C k then A 1 A 2 …A n  C 1 C 2 …C k COMPLEMENTATION Rule If A 1 A 2 …A n  B 1 B 2 …B m then A 1 A 2 …A n  C 1 C 2 …C k where C 1 C 2 …C k is all attributes in R except (A 1 A 2 …A n  B 1 B 2 …B m ) UNION Rule If X 1 X 2 …X n  Y 1 Y 2 …Y m and X 1 X 2 …X n  Z 1 Z 2 …Z k then X 1 X 2 …X n  (Y 1 Y 2 …Y m  Z 1 Z 2 …Z k )

Lecture 11© CIS Spring 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 A 1 A 2 …A n  B 1 B 2 …B m, A 1 A 2 …A n is a superkey Note: Since every FD is also an MVD, 4NF implies BCNF Example: Stars is not in 4NF

Lecture 11© CIS Spring 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 closure for FD’s Fortunately, can get by using transitive rule, complementation rule, intersection rule, and union rule

Lecture 11© CIS Spring 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 ?

Lecture 11© CIS Spring 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.

Lecture 11© CIS Spring 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.

Lecture 11© CIS Spring Exercise Suppose we have relation R(A,B,C) with MVD A  B. If we know that the tuples (a,b 1,c 1 ), (a,b 2,c 2 ), and (a,b 3,c 3 ) are in the current instance of R, what other tuples do we know must also be in R?

Lecture 11© CIS Spring 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.

Lecture 11© CIS Spring Relationships Among Normal Forms Relations in BCNF Relations in 3NF Relations in 4NF