Instructor: Mohamed Eltabakh

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Normalization 1 Instructor: Mohamed Eltabakh Part II.
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
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.
Normal Form Design addendum by C. Zaniolo. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Normal Form Design Compute the canonical cover.
Design Theory.
1 Normalization Chapter What it’s all about Given a relation, R, and a set of functional dependencies, F, on R. Assume that R is not in a desirable.
1 CMSC424, Spring 2005 CMSC424: Database Design Lecture 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.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
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.
THIRD NORMAL FORM (3NF) A relation R is in BCNF if whenever a FD XA holds in R, one of the following statements is true: XA is a trivial FD, or X is.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh
Revisit FDs & BCNF Normalization 1 Instructor: Mohamed Eltabakh
Final Exam Revision Instructor: Mohamed Eltabakh 1.
Christoph F. Eick: Functional Dependencies, BCNF, and Normalization 1 Functional Dependencies, BCNF and Normalization.
Database Systems/COMP4910/Spring02/Melikyan1 Schema Refinement and Normal Forms.
Minimum Cover of F. Minimal Cover for a Set of FDs Minimal cover G for a set of FDs F: –Closure of F = closure of G. –Right hand side of each FD in G.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 15.
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
© 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.
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
Normal Forms Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems June 18, 2016 Some slide content courtesy of Susan Davidson.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh Part 2.
Normalization Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 19.
Functional Dependency and Normalization
Schedule Today: Next After that Normal Forms. Section 3.6.
Relational Database Design (Discussion Session)
Schema Refinement and Normal Forms
Module 5: Overview of Database Design -- Normalization
Normalization First Normal Form (1NF) Boyce-Codd Normal Form (BCNF)
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.
Handout 4 Functional Dependencies
Chapter 8: Relational Database Design
Functional Dependencies and Normalization
Schema Refinement and Normalization
Canonical Cover & Normal Forms
Lecture 6: Design Theory
Normalization Murali Mani.
Schema Refinement and Normal Forms
Functional Dependencies and Normalization
Functional Dependencies and Normalization
Normalization Part II cs3431.
Functional Dependencies and Normalization
Lecture 8: Database Design
Normalization cs3431.
CS 405G: Introduction to Database Systems
Instructor: Mohamed Eltabakh
Designing Relational Databases
Schema Refinement and Normal Forms
Schema Refinement and Normalization
CSC 453 Database Systems Lecture
Database Design Dr. M.E. Fayad, Professor
Functional Dependencies and Normalization
Functional Dependencies and Normalization
CS4222 Principles of Database System
Presentation transcript:

Instructor: Mohamed Eltabakh meltabakh@cs.wpi.edu Normalization- 3NF Part III Instructor: Mohamed Eltabakh meltabakh@cs.wpi.edu

Announcements Homework 2 is due NOW !!! Homework 3 will be out today (Nov. 15) and due on Nov. 22, 8:00AM Midterm on Nov. 22 Until Normalization (Normalization is included) Next lecture is mostly revision + short quiz

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 can be checked on individual relations without computing a join There is always a lossless-join, dependency-preserving decomposition into 3NF

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)

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) 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 (propNo, county, lotNum, area, price) County (county, taxRate) Candidate key for Lot: <county, lotNum> FDs: county  taxRate area  price Decomposition based on area  price Lot (propNo, county, lotNum, area) County (county, taxRate) Area (area, price) Is every relation in 3NF ? YES

Main Idea of the 3NF Decomposition Use the decomposition algorithm as in BCNF But to ensure dependency preservation If α  β is not preserved, then create relation (α, β) where α is the key To ensure the result of decomposition is dependency-preserving and lossless Use the canonical cover in the decomposition 7

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 8

Computing the Canonical Cover Given a set of functional dependencies F, how to compute the canonical cover G Use the next algorithm for this step

Finding Extraneous Attributes

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

Use of Canonical Cover Used in the decomposition of relations to be in 3NF The resulting decomposition is lossless and dependency preserving

Summary of Normalization Normalization forms First Normal Form (1NF) BCNF Third Normal Form (2NF) Fourth Normal Form (4NF) – Not covered Used to ensure the database design is in a good form Decomposing the relation according to functional dependencies