Copyright © 2003-2012 Curt Hill Schema Refinement III 4 th NF and 5 th NF.

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Functional Dependencies (FDs)
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.
1/22/20091 Study the methods of first, second, third, Boyce-Codd, fourth and fifth normal form for relational database design, in order to eliminate data.
NORMALIZATION. Normalization Normalization: The process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations.
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.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Relational Database Design - part 2 - Database Management Systems I Alex Coman,
Nov 11, 2003Murali Mani Normalization B term 2004: lecture 7, 8, 9.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Normal Form Design addendum by C. Zaniolo. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Normal Form Design Compute the canonical cover.
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. 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 | 
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 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.
Chapter 13 Further Normalization II: Higher Normal Forms.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Normalization for Relational Databases.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
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.
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.
Normal Forms through BCNF CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
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.
CSE314 Database Systems Basics of Functional Dependencies and Normalization for Relational Databases Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E.
Chapter 11: Relational Database Design Algorithms and Further Dependencies Chapter 11: Relational Database Design Algorithms and Further Dependencies 1.
IST 210 Normalization 2 Todd Bacastow IST 210. Normalization Methods Inspection Closure Functional dependencies are key.
1 Lecture 7: Normal Forms, Relational Algebra Monday, 10/15/2001.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Design Process - Where are we?
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
Normalization. 2 u Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data,
Normalization.
Functional Dependencies and Relational Schema Design.
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.
Multivalued Dependencies Fourth Normal Form Tony Palladino 157B.
Multivalued Dependencies and 4th NF CIS 4301 Lecture Notes Lecture /21/2006.
CS 338Database Design and Normal Forms9-1 Database Design and Normal Forms Lecture Topics Measuring the quality of a schema Schema design with normalization.
© 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.
Objectives of Normalization  To create a formal framework for analyzing relation schemas based on their keys and on the functional dependencies among.
Copyright © Curt Hill Schema Refinement II 2 nd NF to 3 rd NF to BCNF.
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.
Chapter 14 Functional Dependencies and Normalization Informal Design Guidelines for Relational Databases –Semantics of the Relation Attributes –Redundant.
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
Advanced Normalization
Normalization Refine data To attain a good DB design
Mulitvalued Dependencies
Chapter 7a: Overview of Database Design -- Normalization
Presentation transcript:

Copyright © Curt Hill Schema Refinement III 4 th NF and 5 th NF

Copyright © Curt Hill Now what? An example Consider a table that contains courses, instructors and textbooks There may be multiple instructors for multiple sections of the class There may be multiple textbooks as well Both instructors and textbooks come from a set of possibilities

Copyright © Curt Hill Course/Instructor/Book DeptNumberInstructorBook CIS385221Smith & Boss CIS385221Noble CIS385403Smith & Boss CIS385403Noble Key is entire tuple Each instructor uses two books for the course There is a redundancy

Copyright © Curt Hill Commentary There is redundancy that we should deal with The table is in BCNF –No examination of FDs will help us The two instructors and two textbooks are both determined by the course department and number This is an example of a MultiValued Dependency

Commentary Again First normal form disallows repeating groups A repeating group is often a set A MultiValued Dependecy is a set depending on an item Examples: –People working on many projects –Each of these have many dependents Copyright © Curt Hill

Examples In this example the course determines a set of instructors The course also determines a set of textbooks These two sets are independent If the sets are large we get plenty of redundancy and yet are still in BCNF –If we have every book connected to every instructor connected to the course Copyright © Curt Hill

MultiValue Dependency An MVD determines a value from a set Notation is two arrows Dept,Number  Instructor and Dept,Number  Book The correct decomposition is splitting teacher from book

Copyright © Curt Hill Course/Instructor/Book DeptNumberInstructorBook CIS385221Smith & Boss CIS385221Noble CIS385403Smith & Boss CIS385403Noble DeptNumInstruct CIS CIS DeptNumBook CIS385Smith & Boss CIS385Noble Project into

Copyright © Curt Hill Fourth Normal Form The above two tables are in 4 th NF A table is in 4 th NF if and only if The table is in BCNF All MVDs are now FDs If there are no MVDs then BCNF is also 4NF

Copyright © Curt Hill Another View of 4 th NF If a relation is in 4 th NF then for each MVD, X  A one of the following must hold The MVD is trivial –A is part of X or –XA is the whole relation X is a superkey

Copyright © Curt Hill Is this 4 th NF? DeptNumberInstructorBook CIS385221Smith & Boss CIS385221Noble CIS385403Smith & Boss CIS385403Noble There are two MVDs –Dept,Number  Instructor –Dept,Number  Book Trivial MVDs? - No Dept,Number superkey? - No

Copyright © Curt Hill Is this 4 th NF? DeptNumInstruct CIS CIS There is one MVD –Dept,Num  Instructor Trivial MVD? –Yes, this is whole relation

Copyright © Curt Hill Decomposability A strange thing happens: There are relations that may not be lossless join decomposed into two relations But they can be decomposed into larger number of relations The following example shows a relation that can be decomposed into three but not two

Copyright © Curt Hill SPJ A Example

Copyright © Curt Hill What about this? What is the key? –Entire tuple –Must be in 4 th NF What MVDs? –S  P –S  J –P  J –Among others

Decomposition In the next slide we will see the table decomposed into tables of two fields However, no two of them can be joined into the original without extra rows All three of them can be joined into the original Copyright © Curt Hill

SPJ SJ SP PJ SPJ SPJ A BCD Example Decomposed

Copyright © Curt Hill What Just Happened? A could not be lossless join decomposed into any two of {B, C, D} –Decomposing into just two must break an MVD It could be lossless join decomposed into all three There is a join dependency between A and {B, C, D} There is no join dependency between any of –A and {B, C} –A and {B, D} –A and {C, D}

Copyright © Curt Hill Join Dependencies A Join Dependency {R 1,R 2,…R N } holds over R if R 1,R 2,…R N is a lossless join decomposition of R –In other words, joining R 1,R 2,…R N gives R Notation:  {R 1,R 2,…R N } A JD is a generalization of MVDs In the previous example, the MVDs S  P S  J P  J may be expressed as the join dependency  {B,C,D}

Copyright © Curt Hill Trivial Join Decompositions The join dependency  {R 1,R 2,…R N } on R is trivial iff –At least one of R 1,R 2,…R N is the set of all attributes of R –In other words, there is a relation equivalent to R in the decomposition Joining R to any decomposition of R or its join reproduces the original

Copyright © Curt Hill Implied Join Dependencies Suppose the join dependency  {R 1,R 2,…R N } on R This Join Dependency is Implied by the Candidate Key(s) iff Each relation R 1,R 2,…R N is a superkey for R

Copyright © Curt Hill Fifth Normal Form 5 th NF is also known as: Projection Join Normal Form (PJNF) A relation R is in 5 th NF if and only if every non-trivial join dependency that is satisfied by R is implied by the candidate key(s) of R

Copyright © Curt Hill SPJ Is this in 5 th NF? There is a non-trivial join decomposition,  {B,C,D} –None of these are A This decomposition is not implied by the only candidate key, SPJ –None of these contain SPJ No – not in 5NF

Copyright © Curt Hill Is 5 th NF the Ultimate? It is the ultimate that can be obtained with just projections –The guaranteed best in terms of a lack of anomalies that can be removed by projections Hence the name Join Projection Normal Form However, there may be some anomalies that cannot be eliminated with just projections

Copyright © Curt Hill JDs and FDs FDs and MVDs have a set of inference rules –This allows us to reason about them JDs lack this set Thus finding JDs and using them to move to 5 th NF has its problems We do have one tool

Copyright © Curt Hill 3NF and 5NF If a relation is in 3 rd NF and each of its keys is atomic then the relation is also in 5 th NF –The same may be said on BCNF There may be 5 th NF relations that do not have atomic keys When we can apply this we can determine the table is in 5 th NF without any consideration of JDs

Copyright © Curt Hill Denormalization The argument against making everything 5 th NF: –Lots of separate relations –These relations become separate files –This means lots of I/O Since SQL cannot separate a relation from a file, the argument has some merit

Conclusion MVD are much less common than FD Thus tables that are in BCNF are very often in 5NF because there are no MVDs MVDs are also harder to observe and reason about Thus 3NF and BCNF are the most common normal forms Copyright © Curt Hill