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 | 

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Shantanu Narang.  Background  Why and What of Normalization  Quick Overview of Lower Normal Forms  Higher Order Normal Forms.
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.
1 CS 430 Database Theory Winter 2005 Lecture 9: Fourth and Fifth Normal Forms.
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,…)
Chapter Design Objectives Obtain the theoretically “best” design (normalize) –Remove redundancy and update anomalies –Remove nulls –Minimize the.
Multivalued Dependency Prof. Sin-Min Lee Department of Computer Science.
Classroom Exercise: Normalization
 10.1 CS 728 Advanced Database Systems Chapter 11 Relational Database Design Algorithms and Further Dependencies.
An Information-Theoretic Approach to Normal Forms for Relational and XML Data Marcelo Arenas Leonid Libkin University of Toronto.
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:
CMSC424: Database Design Instructor: Amol Deshpande
Normal Form Design addendum by C. Zaniolo. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Normal Form Design Compute the canonical cover.
Multivalued Dependency Prof. Sin-Min Lee Department of Computer Science.
Decomposition By Yuhung Chen CS157A Section 2 October
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.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
1 Triggers: Correction. 2 Mutating Tables (Explanation) The problems with mutating tables are mainly with FOR EACH ROW triggers STATEMENT triggers can.
Department of Computer Science and Engineering, HKUST Slide 1 7. Relational Database Design.
Chapter 11 Relational Database Design Algorithms and Further Dependencies Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Chapter 8 Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Introduction to Schema Refinement
Ch 7: Normalization-Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
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.
Schema Refinement and Normalization. Functional Dependencies (Review) A functional dependency X  Y holds over relation schema R if, for every allowable.
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.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide DESIGNING A SET OF RELATIONS (2) Goals: Lossless join property (a must). Dependency.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 4 Normalization.
BCNF & Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science.
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.
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.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Appendix B: Advanced.
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
Normalization.
Functional Dependencies and Relational Schema Design.
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.
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.
© 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.
Normal Forms Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems June 18, 2016 Some slide content courtesy of Susan Davidson.
Design Theory for Relational Databases Functional Dependencies Decompositions Normal Forms: BCNF, Third Normal Form Introduction to Multivalued Dependencies.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
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.
Chapter 15 Relational Design Algorithms and Further Dependencies
Module 5: Overview of Normalization
Appendix C: Advanced Normalization Theory
Appendix C: Advanced Relational Database Design
Chapter 28: Advanced Relational Database Design
Chapter 7a: Overview of Database Design -- Normalization
Presentation transcript:

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 |  |  AC r This always holds when we build r by joining relationship sets in this way. In general, however, if we arbitrarily create a relation, this may not happen. Add to r, for example, then r   AB r |  |  AC r because the join also yields, which is not in r. Note: r is the cross product of B and C wrt A.

MVDs: 2 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 x 2 a y 2 b y 2 a x Observe: r =  AB r |  |  AC r This always holds when we build r by joining relationship sets in this way. In general, however, if we arbitrarily create a relation, this may not happen. Add to r, for example, then r   AB r |  |  AC r because the join also yields, which is not in r. Note: r is the cross product of B and C wrt A.

MVDs: 3 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 |  |  AC r This always holds when we build r by joining relationship sets in this way. In general, however, if we arbitrarily create a relation, this may not happen. Add to r, for example, then r   AB r |  |  AC r because the join also yields, which is not in r. Note: r is the cross product of B and C wrt A. Note: All circled values are redundant.* *A value v in a relation is redundant if, from the constraints and other data values in the relation, v can only have the value it has.

MVDs: 4 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 3 x 2 a y 3 a 2 b y Observe: r =  AB r |  |  AC r This always holds when we build r by joining relationship sets in this way. In general, however, if we arbitrarily create a relation, this may not happen. Add to r, for example, then r   AB r |  |  AC r because the join also yields, which is not in r. Note: r is the cross product of B and C wrt A. Note: All circled values are redundant. Doesn’t work 3

MVDs: 5 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 1 z 2 a y 2 b y Observe: r =  AB r |  |  AC r This always holds when we build r by joining relationship sets in this way. In general, however, if we arbitrarily create a relation, this may not happen. Add to r, for example, then r   AB r |  |  AC r because the join also yields, which is not in r. Note: r is the cross product of B and C wrt A. Note: All circled values are redundant. Doesn’t work z

MVDs: 6 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 z 2 a y 2 b y Observe: r =  AB r |  |  AC r This always holds when we build r by joining relationship sets in this way. In general, however, if we arbitrarily create a relation, this may not happen. Add to r, for example, then r   AB r |  |  AC r because the join also yields, which is not in r. Note: r is the cross product of B and C wrt A. Note: All circled values are redundant. Doesn’t work z

MVDs: 7 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 3 b 3 y 2 a y 2 b y Observe: r =  AB r |  |  AC r This always holds when we build r by joining relationship sets in this way. In general, however, if we arbitrarily create a relation, this may not happen. Add to r, for example, then r   AB r |  |  AC r because the join also yields, which is not in r. Note: r is the cross product of B and C wrt A. Note: All circled values are redundant. Does work 3

MVDs: 8 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 c 2 a y 2 b y Observe: r =  AB r |  |  AC r This always holds when we build r by joining relationship sets in this way. In general, however, if we arbitrarily create a relation, this may not happen. Add to r, for example, then r   AB r |  |  AC r because the join also yields, which is not in r. Note: r is the cross product of B and C wrt A. Note: All circled values are redundant. Does work c

MVDs: 9 Join Dependencies—Definitions A join dependency (JD) denoted |  |(R1, …, Rn) holds for a relation r(R) if r =  R1 r |  | … |  |  Rn r. (e.g., |  |(AB, AC) in the previous example) When n = 2, we call a JD a Multivalued Dependency (MVD) and write X Y or X Z or X Y | Z where X = R1  R2, Y = R1  R2, and Z = R2  R1. (e.g., A B or A C or A B | C) Note: every FD is an MVD (e.g., if A  B in a relational schema ABC, then |  |(AB, AC)).  

MVDs: 10 4NF Let R be a relation scheme and let D be a set of MVDs and FDs over R. R is in Fourth Normal Form (4NF) with respect to D if for every nontrivial MVD X Y  D +, X is a superkey of R. An MVD is trivial if Y  X or XY = R. Example: –R = ABC & D = {A B} = {A B|C} = {|  |(AB, AC)} –No FDs, thus the key is ABC –A B is nontrivial and A is not a superkey; thus ABC is not in 4NF –Decompose: AB, AC (both are in 4NF wrt D) A B C    

MVDs: 11 4NF Let R be a relation scheme and let D be a set of MVDs and FDs over R. R is in Fourth Normal Form (4NF) with respect to D if for every nontrivial MVD X Y  D +, X is a superkey of R. An MVD is trivial if Y  X or XY = R. Example: –R = ABC & D = {A  B} ~ {A B|C} = {|  |(AB, AC)} –Since A  B is an FD, the key is AC –A B is a nontrivial FD and a nontrivial MVD and A is not a superkey; thus ABC is not in 4NF –Decompose: AB, AC (both are in 4NF wrt D) A B C   

MVDs: 12 4NF Let R be a relation scheme and let D be a set of MVDs and FDs over R. R is in Fourth Normal Form (4NF) with respect to D if for every nontrivial MVD X Y  D +, X is a superkey of R. An MVD is trivial if Y  X or XY = R. Example: –R = ABC & D = {A  B, A  C} ~ {A B|C} = {|  |(AB, AC)} –The key is A –Both A  B and A  C are nontrivial FDs and nontrivial MVDs, but A is a key of R –Thus ABC is in 4NF A B C  

MVDs: 13 4NF Let R be a relation scheme and let D be a set of MVDs and FDs over R. R is in Fourth Normal Form (4NF) with respect to D if for every nontrivial MVD X Y  D +, X is a superkey of R. An MVD is trivial if Y  X or XY = R. Example: –R = ABC –If a nontrivial MVD X Y holds for R and X is not a superkey, R is not in 4NF  decompose –Otherwise, R is in 4NF  don’t decompose A B C Note that the real question here is whether an n-ary relationship set can be losslessly decomposed into two or more relationship sets.  

MVDs: 14 N-ary Relationship-Set Reduction Guest Date Room View = Guest Date Room |  | Room View G1 10 May R1 Sea G1 10 May R1 R1 Sea G1 10 May R1 Forest G1 15 May R2 R1 Forest G1 15 May R2 Forest G2 15 May R1 R2 Forest G2 15 May R1 Sea G2 15 May R1 Forest

MVDs: 15 Non-reducible N-ary Edge r = Guest Date Room G1 10 May R1 G1 15 May R2 G2 15 May R1 p = Guest Date q = Date Room s = Guest Room G1 10 May 10 May R1 G1 R1 G1 15 May 15 May R2 G1 R2 G2 15 May 15 May R1 G2 R1 r  p |  | q r  q |  | s r  p |  | s r  p |  | q |  | s

MVDs: 16 4NF/5NF/PJNF 4NF definition Let R be a relation scheme and let D be a set of MVDs and FDs over R. R is in Fourth Normal Form (4NF) with respect to D if for every nontrivial MVD X Y  D +, X is a superkey of R. 4NF definition rewritten so that it can be generalized Let R be a relation scheme and let D be a set of MVDs and FDs over R (join dependencies over R, JDs over R). R is in Fourth Normal Form (4NF) with respect to D if for every nontrivial JD |  |(R 1, R 2 ) such that R = R 1 R 2, both R 1 and R 2 are superkeys of R. |  |(XY, XZ) 

MVDs: 17 4NF/5NF/PJNF 4NF definition rewritten so that it can be generalized Let R be a relation scheme and let D be a set of MVDs and FDs over R (join dependencies over R, JDs over R). R is in Fourth Normal Form (4NF) with respect to D if for every nontrivial JD |  |(R 1, R 2 ) such that R = R 1 R 2, both R 1 and R 2 are superkeys of R. 5NF definition Let R be a relation scheme and let D be a set of JDs over R. R is in Fifth Normal Form (5NF) with respect to D if for every nontrivial JD |  |(R 1, R 2, R 3 ) such that R = R 1 R 2 R 3 every R i is a superkey of R.

MVDs: 18 4NF/5NF/PJNF 5NF definition Let R be a relation scheme and let D be a set of JDs over R. R is in Fifth Normal Form (5NF) with respect to D if for every nontrivial JD |  |(R 1, R 2, R 3 ) such that R = R 1 R 2 R 3 every R i is a superkey of R. PJNF definition Let R be a relation scheme and let D be a set of JDs over R. R is in Project-Join Normal Form (PJNF) with respect to D if for every nontrivial JD |  |(R 1, …, R n ) such that R = R 1 …R n every R i is a superkey of R.

MVDs: 19 Normalization into PJNF Decompose wrt JDs The only real question is whether an n-ary relationship set can be losslessly decomposed into two or more relationship sets. –If so, decompose –When all relationship sets are decomposed: A database schema consisting of these relationship sets is in PJNF. Based on the FDs, some of the schemas can be joined without introducing redundancy.