Copyright © 2003-2012 Curt Hill Schema Refinement II 2 nd NF to 3 rd NF to BCNF.

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Normalization Decomposition techniques for ensuring: Lossless joins Dependency preservation Redundancy avoidance We will look at some normal forms: Boyce-Codd.
Schema Refinement and Normal Forms Given a design, how do we know it is good or not? What is the best design? Can a bad design be transformed into a good.
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.
NORMALIZATION FIRST NORMAL FORM (1NF): A relation R is in 1NF if all attributes have atomic value = one value for an attribute = no repeating groups =
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.
Chapter 8 Normal Forms Based on Functional Dependencies Deborah Costa Oct 18, 2007.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Boyce-Codd Normal Form Kelvin Nishikawa SE157a-03 Fall 2006 Kelvin Nishikawa SE157a-03 Fall 2006.
1 Database Design Theory Which tables to have in a database Normalization.
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
Chapter 5 Normalization of Database Tables
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 5 Normalization of Database Tables.
Databases 6: Normalization
NORMALIZATION N. HARIKA (CSC).
Normalization II. Boyce–Codd Normal Form (BCNF) Based on functional dependencies that take into account all candidate keys in a relation, however BCNF.
Chapter 8 Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Introduction to Schema Refinement
Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 29 – 04 – 2005.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
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.
NormalizationNormalization Chapter 4. Purpose of Normalization Normalization  A technique for producing a set of relations with desirable properties,
Bordoloi Database Design: Normalization Dr. Bijoy Bordoloi.
CS 405G: Introduction to Database Systems 18. Normal Forms and Normalization.
Concepts of Database Management, Fifth Edition
Database Management COP4540, SCS, FIU Relation Normalization (Chapter 14)
Announcements Read 5.8 – 5.13 for Monday Project Step 3, due Monday 10/18 Homework 4, due Friday 10/15 – by (or turn in Monday in class)
King Saud University College of Computer & Information Sciences Computer Science Department CS 380 Introduction to Database Systems Functional Dependencies.
Normalization. Learners Support Publications 2 Objectives u The purpose of normalization. u The problems associated with redundant data.
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.
Objectives of Normalization Develop a good description of the data, its relationships and constraints Produce a stable set of relations that Is a faithful.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
Schema Refinement and Normal Forms 20131CS3754 Class Notes #7, John Shieh.
Chapter 7 1 Database Principles Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that.
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.
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)
Further Normalization I
By Abdul Rashid Ahmad. E.F. Codd proposed three normal forms: The first, second, and third normal forms 1NF, 2NF and 3NF are based on the functional dependencies.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh
Lecture No 14 Functional Dependencies & Normalization ( III ) Mar 04 th 2011 Database Systems.
1 Functional Dependencies and Normalization Chapter 15.
IST 210 Normalization 2 Todd Bacastow IST 210. Normalization Methods Inspection Closure Functional dependencies are key.
Temple University – CIS Dept. CIS331– Principles of Database Systems V. Megalooikonomou Database Design and Normalization (based on notes by Silberchatz,Korth,
Copyright, Harris Corporation & Ophir Frieder, The Process of Normalization.
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.
What is normalization ? Proposed by Codd in 1972 Takes a relation through a series of steps to certify whether it satisfies a certain normal form Initially.
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.
CS 405G: Introduction to Database Systems Database Normalization.
CS 338Database Design and Normal Forms9-1 Database Design and Normal Forms Lecture Topics Measuring the quality of a schema Schema design with normalization.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Database design and normalization.
Ch 7: Normalization-Part 1
© 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.
1 Dept. of CIS, Temple Univ. CIS661 – Principles of Data Management V. Megalooikonomou Database design and normalization (based on slides by C. Faloutsos.
11/06/97J-1 Principles of Relational Design Chapter 12.
Objectives of Normalization  To create a formal framework for analyzing relation schemas based on their keys and on the functional dependencies among.
Normalization Or theoretical and common sense approaches to redesigning a database.
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
Relational Data Model, Review Relation Tuple Attribute Domains Candidate key, primary key Key attribute, non-key attribute.
Normal Forms 1NF – A table that qualifies as a relation is in 1NF. (Back)(Back) 2NF – A relation is in 2NF if all of its nonkey attributes are dependent.
Schema Refinement What and why
Presentation transcript:

Copyright © Curt Hill Schema Refinement II 2 nd NF to 3 rd NF to BCNF

Copyright © Curt Hill Recap First Normal Form is just a standard rectangular table No repeating groups It is good, but may have anomalies –Insert Need extra info to insert –Delete Extra info may be lost when deleting –Update Multiple updates may be needed

Copyright © Curt Hill Functional Dependencies Why? –The analysis of the FDs shows the problems with First and Second Normal Forms –Why Third and Boyce-Codd Normal Forms are better Notation: A  B This is read: A determines B Or: B is dependent on A B is fully functionally dependent on A –B is functionally dependent on A –B is not functionally dependent on any subset of A –Notation is A ↠ B

Copyright © Curt Hill Lossless Join Decomposition The goal is to project a table in a lower normal form into several tables of higher normal form This is done using a lossless join decomposition Occurs when no dependencies are broken When the tables are joined, exact original table is reproduced

Copyright © Curt Hill Second Normal Form (2 nd NF) A table is in Second Normal Form if and only if It is in 1 st NF and Every non-key attribute is fully functionally dependent on the whole key Eliminates partial dependencies

Copyright © Curt Hill Partial Dependencies Key X A X  A X is part of key but not all of it Violation of 2 nd NF

Copyright © Curt Hill Student File Revisited SIDSNameLCodeStatus 21JonesA11 32SmithA11 36EricsonA32 39WilliamsA23 This is 2 nd NF but still demonstrates anomalies, because LCode  Status We must know the LCode and Status before an insert Updating Jone’s LCode could put conflicting information in file Deleting Ericson loses all info about LCode A3

Copyright © Curt Hill Transitivity Again Functional dependencies are transitive –If A  B and B  C then A  C –Equality, greater and lesser are also transitive

Copyright © Curt Hill Transitivity is the Problem The Status depends on the LCode The LCode depends on SID which is the key Thus 2 nd NF Status depends directly on a non- key –It depends transitively on the key There are still anomalies because of the transitive dependency

Copyright © Curt Hill Transitive Dependencies SID LCode LCode  Status Lcode is not part of key Status

Copyright © Curt Hill Third Normal Form A table is in 3 rd Normal Form if and only if The table is 2 nd NF Every non-key item is intransitively dependent on the key –In other words: Each item not in the key depends directly on the key and does not depend on anything not in the key

Copyright © Curt Hill Another view of 3 rd NF For each Functional Dependency in the relation R, X  A then one of the following conditions must be true The FD is trivial –A is part of X, so dependency is trivial X is a superkey –The key plus additional fields A is part of some key for R

Copyright © Curt Hill Student File Revisited SIDSNameLCodeStatus 21JonesA11 32SmithA11 36EricsonA32 39WilliamsA23 Is? LCode  Status –The FD is trivial - No –X is a superkey - No –A is part of some key for R – No Not in 3 rd Normal Form

Copyright © Curt Hill So how do we fix? Projection! SIDSNameLCodeStatus 21JonesA11 32SmithA11 36EricsonA32 39WilliamsA23 SIDSNameLCode 21JonesA1 32SmithA1 36EricsonA3 39WilliamsA2 LCodeStatus A11 A32 A23 Becomes

Notes With LCode and Status in a separate table some anomalies are eliminated No deletion of a student loses LCode information No insertion of a student needs status information, so it cannot be in conflict with other status information Changing status and LCode only needs a single update Copyright © Curt Hill

Boyce-Codd Normal Form Slight strengthening of 3 rd NF A table is in 3 rd NF iff –The table is 2 nd NF –Every non-key item is intransitively dependent on the the key A table is in Boyce-Codd NF iff –The table is 2 nd NF –Every item is dependent only on the key

Copyright © Curt Hill 3 rd NF and BCNF For each FD in the relation R, X  A One of the following conditions must be true for 3 rd NF –The FD is trivial –X is a superkey –A is part of some key for R One of the following conditions must be true for BCNF –The FD is trivial –X is a superkey

Copyright © Curt Hill Explanation Many consider 3 rd NF and BCNF as identical What 3 rd NF does not consider is the possibility of alternate keys The definition of a key in 3 rd NF is the primary or other candidate key BCNF forces everything to be dependent on only the primary key

Copyright © Curt Hill 3NF and BCNF Key X A X A Disallowed by 3NF and BCNF Disallowed by BCNF

Copyright © Curt Hill The catchy saying Each item should be dependent on: the key (1 st NF) the whole key (2 nd NF) and nothing but the key (BCNF)

Copyright © Curt Hill 3NF or BCNF? Is there a practical difference? Yes BCNF is slightly stronger –It eliminates a type of redundancy –It may also introduce another problem

Copyright © Curt Hill An example Relation has 6 attributes: ABCDEF FDs: A  ABCDEF (A is key) CE  A (CE is also a key) BD  E Not BCNF, but is 3NF –BD is not a key Project into ABCDF and BDE to make it BCNF

Copyright © Curt Hill Problem with this Projection Project into ABCDF and BDE This is a lossless join decomposition Now in BCNF There is an integrity constraint issue –CE  A cannot be checked without doing a join This was not a dependency preserving decomposition

Copyright © Curt Hill Testing for Dependency Preserving Decompositions If we decompose relation R into S and T If the R + = (S U T) + –Then it is dependency preserving This was not ABCDF and BDE –CE  A is in R + but not in (S U T) + –Neither relation had all three fields

Copyright © Curt Hill Decompositions May Be: Lossless join Dependency preserving Both (clearly the preferred) Neither There is always a lossless join and dependency preserving decomposition into 3NF This is not always the case with BCNF –We can always get to BCNF –Is it desirable?

Copyright © Curt Hill Perspective Some redundancy is allowed in 3NF that is disallowed in BCNF We can not always get to BCNF with dependency preserving decompositions –Even though we can always get to BCNF We then have to decide where to stop We may actually settle for 2NF for other reasons –Such as efficient queries

Copyright © Curt Hill Final Thoughts This is far as FDs and FFDs may be pushed Higher normal forms require looking at something else Fourth Normal Form requires consideration of multi-valued dependencies