Normalization First Normal Form (1NF) Boyce-Codd Normal Form (BCNF)

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Normalization 1 Instructor: Mohamed Eltabakh Part II.
Murali Mani Normalization. Murali Mani What and Why Normalization? To remove potential redundancy in design Redundancy causes several anomalies: insert,
CS Algorithm : Decomposition into 3NF  Obviously, the algorithm for lossless join decomp into BCNF can be used to obtain a lossless join decomp.
Normalization DB Tuning CS186 Final Review Session.
Normalization DB Tuning CS186 Final Review Session.
Nov 11, 2003Murali Mani Normalization B term 2004: lecture 7, 8, 9.
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
Cs3431 Normalization Part II. cs3431 Attribute Closure : Example Consider R (A, B, C, D, E) with FDs A  B, B  C, CD  E Does A  E hold ? (Is A  E.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
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.
Schema Refinement and Normal Forms Chapter 19 1 Database Management Systems 3ed, R.Ramakrishnan & J.Gehrke.
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.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
1 Schema Refinement and Normal Forms Chapter The Evils of Redundancy  Redundancy is at the root of several problems associated with relational.
© 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.
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.
1 CS122A: Introduction to Data Management Lecture #13: Relational DB Design Theory (II) Instructor: Chen Li.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh Part 2.
COP 6726: New Directions in Database Systems
Normalization Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 19.
Functional Dependency and Normalization
Advanced Normalization
Design Theory for Relational Databases
Schedule Today: Next After that Normal Forms. Section 3.6.
Relational Database Design (Discussion Session)
Schema Refinement and Normal Forms
CS411 Database Systems 08: Midterm Review Kazuhiro Minami 1.
Module 5: Overview of Database Design -- Normalization
Canonical Cover & Normal Forms
Database Design Dr. M.E. Fayad, Professor
Relational Database Design by Dr. S. Sridhar, Ph. D
Relational Database Design
CS 480: Database Systems Lecture 22 March 6, 2013.
Relational Database Design
Chapter 8: Relational Database Design
Handout 4 Functional Dependencies
Advanced Normalization
Chapter 8: Relational Database Design
Functional Dependencies and Normalization
Schema Refinement and Normalization
Canonical Cover & Normal Forms
Lecture 6: Design Theory
Module 5: Overview of Normalization
Normalization Murali Mani.
Normalization Boyce-Codd Normal Form Presented by: Dr. Samir Tartir
Lecture #17: Schema Refinement & Normalization - Normal Forms
Schema Refinement and Normal Forms
Functional Dependencies and Normalization
Functional Dependencies and Normalization
Normalization Part II cs3431.
Functional Dependencies and Normalization
CS 405G: Introduction to Database Systems
Instructor: Mohamed Eltabakh
Designing Relational Databases
Schema Refinement and Normal Forms
Schema Refinement and Normalization
Relational Database Design
Instructor: Mohamed Eltabakh
Anomalies Boyce-Codd Normal Form 3rd Normal Form
Database Design Dr. M.E. Fayad, Professor
Chapter 7a: Overview of Database Design -- Normalization
Functional Dependencies and Normalization
Functional Dependencies and Normalization
CS4222 Principles of Database System
Presentation transcript:

Normalization First Normal Form (1NF) Boyce-Codd Normal Form (BCNF) Third Normal Form (3NF) Canonical Cover of FDs

Big Picture DB design may be bad and has problems Insert/Update/Delete anomaly Inconsistent data When a FD violates a normalization rule Then, one or more of the problems above exist The decomposition will solve the problem

Third Normal Form: Motivation There are some situations where BCNF is not dependency preserving Solution: Define a weaker normal form, called Third Normal Form (3NF) Allows some redundancy (we will see examples later) But all FDs are preserved There is always a lossless, dependency-preserving decomposition in 3NF

R.H.S consists of prime attributes Normal Form : 3NF Relation R is in 3NF if, for every FD in F+ α  β, where α ⊆ R and β ⊆ R, at least one of the following holds: α → β is trivial (i.e.,β⊆α) α is a superkey for R Each attribute in β-α is part of a candidate key (prime attribute) L.H.S is superkey OR R.H.S consists of prime attributes

Testing for 3NF Use attribute closure to check for each dependency α → β, if α is a superkey If α is not a superkey, we have to verify if each attribute in (β- α) is contained in a candidate key of R

3NF: Example Is relation Lot in 3NF ? Lot (ID, county, lotNum, area, price, taxRate) Primary key: ID Candidate key: <county, lotNum> FDs: county  taxRate area  price Is relation Lot in 3NF ? NO Decomposition based on county  taxRate Lot (ID, county, lotNum, area, price) County (county, taxRate) Are relations Lot and County in 3NF ? Lot is not

3NF: Example (Cont’d) Is every relation in 3NF ? Lot (ID, county, lotNum, area, price) County (county, taxRate) Candidate key for Lot: <county, lotNum> FDs: county  taxRate area  price Decompose Lot based on area  price Lot (ID, county, lotNum, area) County (county, taxRate) Area (area, price) Is every relation in 3NF ? YES

Comparison between 3NF & BCNF ? If R is in BCNF, obviously R is in 3NF If R is in 3NF, R may not be in BCNF 3NF allows some redundancy and is weaker than BCNF 3NF is a compromise to use when BCNF with good constraint enforcement is not achievable Important: Lossless, dependency-preserving decomposition of R into a collection of 3NF relations always possible ! 24

Normalization First Normal Form (1NF) Boyce-Codd Normal Form (BCNF) Third Normal Form (3NF) Canonical Cover of FDs

Canonical Cover of FDs

Canonical Cover of FDs Given set of FDs (F) with functional closure F+ Canonical Cover (Minimal Cover) = G Is the smallest set of FDs that produce the same F+ There are no extra attributes in the L.H.S or R.H.S of and dependency in G Given set of FDs (F) with functional closure F+ Canonical cover of F is the minimal subset of FDs (G), where G+ = F+ Every FD in the canonical cover is needed, otherwise some dependencies are lost 8

Example : Canonical Cover Given F: A  B, ABCD  E, EF  GH, ACDF  EG Then the canonical cover G: A  B, ACD  E, EF  GH The smallest set (minimal) of FDs that can generate F+ 8

Computing the Canonical Cover Given a set of functional dependencies F, how to compute the canonical cover G

Example : Canonical Cover (Lets Check L.H.S) Given F = {A  B, ABCD  E, EF  G, EF  H, ACDF  EG} Union Step: {A  B, ABCD  E, EF  GH, ACDF  EG} Test ABCD  E Check A: {BCD}+ = {BCD}  A cannot be deleted Check B: {ACD}+ = {A B C D E}  Then B can be deleted Now the set is: {A  B, ACD  E, EF  GH, ACDF  EG} Test ACD  E Check C: {AD}+ = {ABD}  C cannot be deleted Check D: {AC}+ = {ABC}  D cannot be deleted 8

Example: Canonical Cover (Lets Check L.H.S-Cont’d) Now the set is: {A  B, ACD  E, EF  GH, ACDF  EG} Test EF  GH Check E: {F}+ = {F}  E cannot be deleted Check F: {E}+ = {E}  F cannot be deleted Test ACDF  EG None of the H.L.S can be deleted 8

Example: Canonical Cover (Lets Check R.H.S) Now the set is: {A  B, ACD  E, EF  GH, ACDF  EG} Test EF  GH Check G: {EF}+ = {E F H}  G cannot be deleted Check H: {EF}+ = {E F G}  H cannot be deleted Test ACDF  EG Check E: {ACDF}+ = {A B C D F E G}  E can be deleted Now the set is: {A  B, ACD  E, EF  GH, ACDF  G} 8

Example: Canonical Cover (Lets Check R.H.S-Cont’d) Now the set is: {A  B, ACD  E, EF  GH, ACDF  G} Test ACDF  G Check G: {ACDF}+ = {A B C D F E G}  G can be deleted Now the set is: {A  B, ACD  E, EF  GH} The canonical cover is: {A  B, ACD  E, EF  GH} 8

Canonical Cover Used to find the smallest (minimal) set of FDs that have the same closure as the original set. Used in the decomposition of relations to be in 3NF The resulting decomposition is lossless and dependency preserving

Done with Normalization First Normal Form (1NF) Boyce-Codd Normal Form (BCNF) Third Normal Form (3NF) Canonical Cover of FDs

Summary (I) Functional Dependencies Decomposition How to derive more FDs FDs   Keys Functional closure and Attribute closure Decomposition Lossy vs. Lossless How to make the decomposition and how to check Dependency Preservation Whether all dependencies are preserved or some FDs are lost

Summary (II) Normalization Canonical Cover Check whether a relation satisfies BCNF or 3rd NF If there are violations, then how to decompose Canonical Cover Given a set of FDs, how to find its canonical cover

Questions ?