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.

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Schema Refinement: Canonical/minimal Covers
primary key constraint foreign key constraint
Schema Refinement and Normal Forms
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Logical Database Design (3 of 3) John Ortiz. Lecture 7Logical Database Design (2)2 Normalization  If a relation is not in BCNF or 3NF, we refine it by.
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.
Normalization theory exercises Dr. Shiyong Lu Department of Computer Science Wayne State University ©copyright 2007, all rights reserved.
1 Design Theory. 2 Minimal Sets of Dependancies A set of dependencies is minimal if: 1.Every right side is a single attribute 2.For no X  A in F and.
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.
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
Properties of Armstrong’s Axioms Soundness All dependencies generated by the Axioms are correct Completeness Repeatedly applying these rules can generate.
CS Algorithm : Decomposition into 3NF  Obviously, the algorithm for lossless join decomp into BCNF can be used to obtain a lossless join decomp.
Classroom Exercise: Normalization
Normalization DB Tuning CS186 Final Review Session.
Normalization DB Tuning CS186 Final Review Session.
CMSC424: Database Design Instructor: Amol Deshpande
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.
Decomposition By Yuhung Chen CS157A Section 2 October
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.
1 Schema Refinement and Normal Forms Yanlei Diao UMass Amherst April 10, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Fall 2001Arthur Keller – CS 1804–1 Schedule Today Oct. 4 (TH) Functional Dependencies and Normalization. u Read Sections Project Part 1 due. Oct.
1 Triggers: Correction. 2 Mutating Tables (Explanation) The problems with mutating tables are mainly with FOR EACH ROW triggers STATEMENT triggers can.
Chapter 14 Advanced Normalization Transparencies © Pearson Education Limited 1995, 2005.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 29 – 04 – 2005.
Chapter 7: Relational Database Design. 7.2Unite International CollegeDatabase Management Systems Chapter 7: Relational Database Design Features of Good.
Schema Refinement and Normal Forms Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
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.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
CSCD34 - Data Management Systems - A. Vaisman1 Schema Refinement and Normal Forms.
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.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
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.
Lecture 09: Functional Dependencies. Outline Functional dependencies (3.4) Rules about FDs (3.5) Design of a Relational schema (3.6)
Computing & Information Sciences Kansas State University Tuesday, 27 Feb 2007CIS 560: Database System Concepts Lecture 18 of 42 Tuesday, 27 February 2007.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh
CHAPTER 19 SCHEMA, REFINEMENT AND NORMAL FORMS
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
1 Schema Refinement and Normal Forms Week 6. 2 The Evils of Redundancy  Redundancy is at the root of several problems associated with relational schemas:
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.
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
Multivalued Dependencies and 4th NF CIS 4301 Lecture Notes Lecture /21/2006.
1 Schema Refinement and Normal Forms Chapter The Evils of Redundancy  Redundancy is at the root of several problems associated with relational.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
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.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
1 CS 430 Database Theory Winter 2005 Lecture 8: Functional Dependencies Second, Third, and Boyce-Codd Normal Forms.
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.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Formal definition of a key A key is a set of attributes A 1,..., A n such that for any other attribute B: A 1,..., A n  B A minimal key is a set of attributes.
Advanced Normalization
Relational Database Design (Discussion Session)
CS411 Database Systems 08: Midterm Review Kazuhiro Minami 1.
Normalization First Normal Form (1NF) Boyce-Codd Normal Form (BCNF)
The Closure of a set of Attributes
CS 480: Database Systems Lecture 22 March 6, 2013.
Functional Dependencies and Normalization
Some slides are from Dr. Sara Cohen
Instructor: Mohamed Eltabakh
CS4222 Principles of Database System
Presentation transcript:

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 a superkey, or A is part of some key

Why 3NF? A relation R is in 3NF 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 a superkey, or A is part of some key By making an exception for certain dependencies involving some key attributes, we can ensure that every relation schema can be decomposed into a collection of 3NF with two desirable properties: lossless-join and dependency-preserving.

Cases of 3NF Violation If XY causes a violation of 3NF, there are two cases: X is a proper subset of some key (partial dependency) Partial dependency causes data redundancy: Since XY and X is not a key, X could be redundant, so Y. X is not a proper subset of any key (transitive dependency) KEY Attributes X Attribute Y KEY Attributes X Attribute Y Attributes X KEY Attribute Y Transitive dependency KXY makes it impossible to record the values of (K, X, Y) unless all of them are known: Since KXY, we cannot associate an X value with a K value unless we also associate an X value with Y value

Dependency-Preserving Decomposition Inputs: A relation R with a set Fmin of FDs that is minimum cover D(R1, R2, …, Rn) is a lossless-join decomposition of R Find all dependencies in Fmin that are not preserved For each such dependency XA, create a relation schema XA and add it to the decomposition of R Every dependency in Fmin is now preserved Proof: XA is in 3rd NF X must be a key for XA, Since XA is in a minimal cover, YA does not hold for any Y that is a subset of X For any other dependencies hold over XA, say YZ, in Fmin, it must satisfy 3rd NF conditions If Z is A, Y must be X If Z is not A, Z must be part of X R and F For each X->Y in F, check if it violates BCNF. If yes, decompose R into R-Y and XY Let R1, …, Rn be the resulted decomposition. Compute F+, and for each X->Y in F+, find its corresponding Ri (if X and Y are both in Ri). This generates F1, …, Fn for R1, …, Rn, respectively. Find Fmin. For each X->Y in Fmin, check if it is included in the union of F1, …, Fn. If not, add XY in R’s decomposition.

A. Lossless-Join Decomposition Top-Down Approach: Lossless-Join and Dependency Preserving Decomposition into 3NF A. Lossless-Join Decomposition Set D{R} While there is a relation schema Q in D that is not in BCNF do begin Choose a relation schema Q in D that is not in BCNF; Find a functional dependency XY in Q that violates BCNF; Replace Q in D by two schemas (Q-Y) and (XUY) end; B. Dependency-Preserving Decomposition Assume the decomposition is D(R1, R2, …, Rn) and the FD sets are accordingly F1, F2, …, and Fn (let their union be F’) For each dependency XA in the original F (needs to be a minimum cover), check if it can be inferred from F’ If not, create a relation schema XA and add it to the decomposition of R

Exercise Top-down approach R(ABCDE) F={ABCDE,ED,AB,ACD} Loss-less join decomposition: R(ACBDE) is not in BCNF 3. Dependency-preserving decomposition: {ABCDE, ED, ABB, ACD}+ == {ACE, AB, ED}+ ?? /* Find a minimum cover first */ /* If XY is not preserved, add (XY) into the decomposition */ ED R1(ACBE) R2(ED) AB R1(ACE) R2(AB)

Bottom-up Approach: Lossless-Join and Dependency Preserving Decomposition into 3NF Inputs: A relation R and a set of functional dependencies F on the attributes of R. Find a minimal cover G of F. For each left-hand side X of a FD G, create a relation schema in D with attributes where XA1, XA2, …, XAm are the only dependencies in G with X as the left-hand side. Prove that this relation is in 3rd NF If none of the relation schemas in D contains a key of R, then create one more relation schema in D that contains attributes that form a key of R. Prove that this decomposition is lossless-join X->Ai is in Fmin. Let Y->Z If Z is Ai, Y must be X, then Y->Z obey BNCF. If Z is not Ai, then Z must be part of X. Since X is a key, Z is part of some key. So Y->Z obey 3NF. Since K determines all other attributes, so

Exercise R(ABCDE) F={ABCDE,ED,AB,ACD} Bottom up approach (Synthesis): Step 1: Find a minimum cover, G={ACE,ED,AB} Step 2: R1(ACE), R2(ED), R3(AB) Step 3: Is this a lossless-join decomposition?

Normalization Review Functional Dependency Normal Forms Decomposition Amstrong’s axioms Attribute closure (A+) Dependency closure (F+) Minimum cover (Fmin) Normal Forms BCNF 3NF Decomposition Lossless join Dependency preserving Conceptual design Schemas ICs

Determine Normal Forms BCNF For each XA, is it a trivial dependency? Is X a superkey? 3NF Suppose XA violate BCNF Is A part of some key?

Exercise 1 For each of the following relation schemas and sets of FDs R(ABCD) with FDs ABC, CD, and DA R(ABCD) with FDs BC and BD. R(ABCD) with FDs ABC, BCD, CDA, and ADB Check if they are in BCNF or 3NF, if not, perform a lossless join and dependency preserving decomposition BCNF For each XA, is it a trivial dependency? Is X a superkey? 3NF Suppose XA violate BCNF Is A part of some key?

Exercise 2 Prove that, if R is in 3NF and every key is simple (i.e, a single attribute), then R is in BCNF Prove that, if R has only one key, it is in BCNF if and only if it is in 3NF.

Quiz For each of the following relation schemas Indicate the strongest normal form of each of the following relations R1(ABCDE) F1={AB, CD, ACEABCDE} R2(ABCEF) F2={ABC, BF, FE} Consider a relation R with five attributes: ABCDE. F={AB, BCE, EDA} Are {ECD}, {ACD}, {BCD} keys for R? Is R in BCNF? Why? Is R in 3NF? Why?

Dependency preservation Conceptual Schema ( ER diagram ) DBMS independent Data Model Mapping DBMS specific Conceptual Schema ( Relations ) Normalization BCNF/3NF? Decomposition Lossless join Dependency preservation