Normal forms First Normal Form (1NF) Second Normal Form (2NF)

Slides:



Advertisements
Similar presentations
Functional Dependencies and Normalization for Relational Databases
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Boyce-Codd NF Takahiko Saito Spring 2005 CS 157A.
NORMALIZATION. Normalization Normalization: The process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations.
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.
Ch 10, Functional Dependencies and Normal forms
Functional Dependencies and Normalization for Relational Databases.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
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.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Lecture 12 Inst: Haya Sammaneh
IS 230Lecture 8Slide 1 Normalization Lecture 9. IS 230Lecture 8Slide 2 Lecture 8: Normalization 1. Normalization 2. Data redundancy and anomalies 3. Spurious.
King Saud University College of Computer & Information Sciences Computer Science Department CS 380 Introduction to Database Systems Functional Dependencies.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Normalization for Relational Databases.
DatabaseIM ISU1 Chapter 10 Functional Dependencies and Normalization for RDBs Fundamentals of Database Systems.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Topic 10 Functional Dependencies and Normalization for Relational Databases Faculty of Information Science and Technology Mahanakorn University of Technology.
Instructor: Churee Techawut Functional Dependencies and Normalization for Relational Databases Chapter 4 CS (204)321 Database System I.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 4 Normalization.
Functional Dependencies and Normalization for Relational Databases.
Revisit FDs & BCNF Normalization 1 Instructor: Mohamed Eltabakh
1 Functional Dependencies and Normalization Chapter 15.
© D. Wong Ch. 3 (continued)  Database design problems  Functional Dependency  Keys of relations  Decompositions based on Functional Dependency.
Lecture 8: Database Concepts May 4, Outline From last lecture: creating views Normalization.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Design Process - Where are we?
Normalization.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
© 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.
Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization.
1 CS 430 Database Theory Winter 2005 Lecture 8: Functional Dependencies Second, Third, and Boyce-Codd Normal Forms.
Al-Imam University Girls Education Center Collage of Computer Science 1 nd Semester, 1432/1433H Chapter 10_part2 Functional Dependencies and Normalization.
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.
Database System Concepts, 5th Ed. ©Sang Ho Lee Chapter 7: Relational Database Design.
Functional Dependencies and Normalization for Relational Databases تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في ذلك. حيث المرجع.
1 Relational Data Model Overview –introduced by E. F. Codd (1970) –strong theoretical foundations –simplicity –numerous commercial systems –has a single.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh Part 2.
10/3/2017.
COP 6726: New Directions in Database Systems
Normalization Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 19.
Functional Dependency and Normalization
CHAPTER 14 Basics of Functional Dependencies and Normalization for Relational Databases.
Schedule Today: Next After that Normal Forms. Section 3.6.
Functional Dependencies and Normalization for Relational Databases
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Functional Dependencies and Normalization for RDBs
3.1 Functional Dependencies
Normalization Refine data To attain a good DB design
Normalization 2NF & 3NF Presented by: Dr. Samir Tartir
Functional Dependencies and Normalization for Relational Databases
Database Management systems Subject Code: 10CS54 Prepared By:
Functional Dependencies and Normalization
Multivalued Dependencies & Fourth Normal Form (4NF)
Mulitvalued Dependencies
Functional Dependencies and Normalization
Sridhar Narayan Normalization Sridhar Narayan
Outline: Normalization
Normalization.
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Unit 7 Normalization (表格正規化).
Normalization February 28, 2019 DB:Normalization.
Schema Refinement and Normal Forms
Chapter Outline 1 Informal Design Guidelines for Relational Databases
Presentation transcript:

Normal forms First Normal Form (1NF) Second Normal Form (2NF) Third Normal Form (3NF) Boyce/Codd Normal Form (BCNF) Fourth Normal Form (4NF) Fifth Normal Form (5NF)

First normal form (1NF) The only attribute values permitted are single atomic (indivisible) Not allow a set, list, bag, etc. considered to be part of the formal definition of a relations

Various functional dependencies Prime and nonprime attribute an attribute of a relation schema R is called a prime attribute of R if it is a member of any candidate key of R an attribute is called nonprime if it is not a prime attribute, i.e. not a member of any candidate key of R Full functional dependency Y is said to be fully dependent on X if X  Y and Z  Y for any X  Z Y is fully dependent on X if and only if Y is functionally dependent on X, and - not functionally dependent on any proper subset of X Partial functional dependency Y is said to be partially dependent on X if some attribute can be removed from X and the dependency still holds Transitive functional dependency

Second Normal Form (2NF) A relation schema R is in 2NF if it is in 1NF and every nonprime attribute A in R is fully functionally dependent on every key of R R(SSN, pNumber, hours, eName, pName, pLocation) SSN pNumber  hours SSN  eName pNumber  pName pLocation decomposed into R1(SSN, pNumber, hours) R2(SSN, eName) R3(pNumber, pName, pLocation)

Example for 1NF and 2NF FIRST(S#, P#, Status, City, Qty) S# P#  Status City Qty S#  City Status City  Status Anomalies insertion: cannot record City for a supplier until he supplies something modification: City for a supplier appears many times deletion: deletion of last tuple for S# lose its City FIRST is not in 2NF, so decompose into SECOND(S#, Status, City) SP(S#, P#, Qty) S#  City Status City  Status S# P#  Qty

Third Normal Form (3NF) A relation schema is in 3NF if it is in 2NF and no nonprime attribute of R is transitively dependent on any key Alternatively, a relation schema R is in 3NF if whenever a nontrivial functional dependency X -->A holds in R, then either (a) X is a super key of R or (b) A is a prime attribute of R EMP_DEPT(SSN, Ename, Bdate, Addr, D#, Dname, Dmgrssn) FDs: SSN  Ename Bdate Addr D# D#  Dname Dmgrssn Since Dname and Dmgrssn are transitively dependent on D# (not in 3NF) ED1(SSN, Ename, Bdate, Addr, D#) ED2(D#, Dname, Dmgrssn)

Example for 2NF and 3NF SECOND(S#, Status, City) SP(S#, P#, Qty) S#  City Status City  Status Anomalies insertion: cannot record new Status for a city without S# modification : Status for a City appears in many tuples deletion : delete only the second tuple for a particular City SECOND is not in 3NF, so decompose into SC(S#,City) CS(City, Status)

Boyce/Codd Normal Form (BCNF) A relation schema R is in BCNF if whenever a nontrivial functional dependency X  A holds in R, then X is a super key of R Difference with 3NF Drop the second condition in 3NF that allows A to be prime if X is not a superkey

3NF and BCNF example MovieStudio(title, year, length, filmType, studioName, studioAddr) title year  length filmType studioName studioName  studioAddr Key: {title, year} Hence, MovieStudio is not 3NF Decompose into MovieStudio1(title, year, length, filmType, studioName) MovieStudio2(studioName, studioAddr) Then we get a schema in BCNF.

All binary relations are in BCNF Let A and B are all attributes Consider all possible cases, here there are totally 4 cases no nontrivial FD at all: {A, B} is a key, so in BCNF A  B holds, B  A does not hold {A} is a key, so in BCNF B  A holds, A  B does not hold: similarly A  B holds, B  A holds {A} and {B} are keys, so in BCNF

Multivalued dependency example EMP(eName, pName, depName) Smith {X,Y} {John, Anna} Must repeat every combination due to 1NF Two independent one-many relationships are mixed in the same relation eName -->> pName eName -->> depName

Multivalued dependency definition Let X, Y be sets of attributes in R Let Z be compliment of X  Y Multivalued dependency (MVD) X -->> Y [X multidetermines Y] holds in R if and only if each X-value in R is associated with a set of Y-values in a way that does not depend on Z-values MVD and FD-MVD rules Complementation If X -->> Y, then X -->> T – X – Y where Ts are all attributes of R not among the A’s and B’s Augmentation If X -->> Y and V  W, XW -->> YV Transitivity If X -->> Y and Y -->>Z, then X -->> Z – Y If X  Y, then X -->> Y (i.e. an FD is a special case of an MVD)

Fourth normal form (4NF) An MVD A1A2 … An -->> B1B2 … Bm for a relation R is trivial if: A’s  B’s or A’s  B’s are all attributes of R A relation R is in 4NF if whenever A1A2 … An -->> B1B2 … Bm is a nontrivial MVD, {A1, A2, …, An} is a superkey

4NF example Star(name, street, city, title, year) name -->> street city Star relation is not in 4NF, hence decompose into Star1(name, street, city) Star2(name, title, year) Note that both new relations are in 4NF

Relationship among normal forms All relation schema 1NF 2NF 3NF BCNF 4NF 5NF In practice, it is best to have relation schemas in BCNF or in 3NF