BCNF and Normalization

Slides:



Advertisements
Similar presentations
1 Lecture 7 Design Theory for Relational Databases (part 1) Slides based on
Advertisements

4NF and 5NF Prof. Sin-Min Lee Department of Computer Science.
Functional Dependencies. Babies At a birth, there is one baby (twins would be represented by two births), one mother, any number of nurses, and a doctor.
Winter 2002Arthur Keller – CS 1804–1 Schedule Today: Jan. 15 (T) u Normal Forms, Multivalued Dependencies. u Read Sections Assignment 1 due. Jan.
1 Normalization Anomalies Boyce-Codd Normal Form 3 rd Normal Form.
1 Normalization Anomalies Boyce-Codd Normal Form 3 rd Normal Form Source: Slides by Jeffrey Ullman.
Fall 2001Arthur Keller – CS 1804–1 Schedule Today Oct. 4 (TH) Functional Dependencies and Normalization. u Read Sections Project Part 1 due. Oct.
1 Normalization Anomalies Boyce-Codd Normal Form 3 rd Normal Form.
Functional Dependencies and Relational Schema Design.
Decompositions uDo we need to decompose a relation? wSeveral normal forms for relations. If schema in these normal forms certain problems don’t.
Database Management Systems Chapter 3 The Relational Data Model (III) Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
Databases 1 Seventh lecture. Topics of the lecture Extended relational algebra Normalization Normal forms 2.
Normalization Goal = BCNF = Boyce-Codd Normal Form = all FD’s follow from the fact “key  everything.” Formally, R is in BCNF if for every nontrivial FD.
Lecture 09: Functional Dependencies. Outline Functional dependencies (3.4) Rules about FDs (3.5) Design of a Relational schema (3.6)
SCUJ. Holliday - coen 1784–1 Schedule Today: u Normal Forms. u Section 3.6. Next u Relational Algebra. Read chapter 5 to page 199 After that u SQL Queries.
IST 210 Normalization 2 Todd Bacastow IST 210. Normalization Methods Inspection Closure Functional dependencies are key.
Functional Dependencies. Outline Functional dependencies (3.4) Rules about FDs (3.5) Design of a Relational schema (3.6)
1 Lecture 7: Normal Forms, Relational Algebra Monday, 10/15/2001.
Functional Dependencies and Relational Schema Design.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Final Review Zaki Malik November 20, Basic Operators Covered.
Computational Biology Dr. Jens Allmer Lecture Slides Week 5.
Design Theory for Relational Databases Functional Dependencies Decompositions Normal Forms: BCNF, Third Normal Form Introduction to Multivalued Dependencies.
1 Lecture 8 Design Theory for Relational Databases (part 2) Slides from
4NF & MULTIVALUED DEPENDENCY By Kristina Miguel. Review  Superkey – a set of attributes which will uniquely identify each tuple in a relation  Candidate.
1 Database Design: DBS CB, 2 nd Edition Physical RDBMS Model: Schema Design and Normalization Ch. 3.
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.
1 CS122A: Introduction to Data Management Lecture #13: Relational DB Design Theory (II) Instructor: Chen Li.
Lecture 11: Functional Dependencies
Design Theory for Relational Databases
Schedule Today: Next After that Normal Forms. Section 3.6.
Schema Refinement and Normal Forms
CS411 Database Systems 08: Midterm Review Kazuhiro Minami 1.
Normalization First Normal Form (1NF) Boyce-Codd Normal Form (BCNF)
CPSC-310 Database Systems
Database Design Dr. M.E. Fayad, Professor
Relational Database Design by Dr. S. Sridhar, Ph. D
Schedule Today: Jan. 23 (wed) Week of Jan 28
3.1 Functional Dependencies
Problems in Designing Schema
CPSC-310 Database Systems
Relational Design Theory
Relational Design Theory
CPSC-310 Database Systems
Module 5: Overview of Normalization
Normalization Murali Mani.
Multivalued Dependencies & Fourth Normal Form (4NF)
Functional Dependencies and Normalization
Functional Dependencies and Relational Schema Design
Multivalued Dependencies & Fourth Normal Form
Multivalued Dependencies & Fourth Normal Form
Introduction to Database Systems CSE 444 Lectures 8 & 9 Database Design October 12 & 15, 2007.
Relational Design Theory
Normalization Part II cs3431.
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
CPSC-310 Database Systems
Lecture 8: Database Design
Boyce-Codd Normal Form
Functional Dependencies
Multivalued Dependencies
Anomalies Boyce-Codd Normal Form 3rd Normal Form
Database Design Dr. M.E. Fayad, Professor
Lecture 6: Functional Dependencies
Lecture 11: Functional Dependencies
Chapter 3: Design theory for relational Databases
Chapter 7a: Overview of Database Design -- Normalization
Functional Dependencies and Normalization
Lecture 09: Functional Dependencies
CS4222 Principles of Database System
Presentation transcript:

BCNF and Normalization Zaki Malik October 21, 2008

Relational Schema Design Goal of relational schema design is to avoid redundancy and anomalies.

Bad Design name addr beersLiked manf favBeer Janeway Voyager Export Molson G.I. Lager Janeway Voyager G.I. Lager Gr. Is. G.I. Lager Spock Enterprise Export Molson Export Redundancy Update anomaly if Janeway is transferred to Intrepid, will we remember to change each of her tuples? Deletion anomaly If nobody likes Export, we lose track of the fact that Molson manufactures Export.

Another Example

Relational Decomposition

Example of Decomposition

Triviality of FDs

Boyce-Codd Normal Form

Closures of FDs vs. Closures of Attributes

Checking for BCNF Violations

Decomposition into BCNF

Decomposing Courses

Decomposing Courses

Another Example of Decomposition

Another Example of Decomposition (2)

BCNFs and Two-Attribute Relationships

Decomposition into BCNF

Candidate Normalization Algorithm

Joining Relations

Recovering Information from a Decomposition

Correct Decompositions A decomposition is lossless if we can recover: R(A,B,C) R1(A,B) R2(A,C) R’(A,B,C) should be the same as R(A,B,C) Decompose Recover R’ is in general larger than R. Must ensure R’ = R

Example of Lossy-Join Decomposition Example: Decomposition of R = (A, B) R1 = (A) R2 = (B) A B A B   1 2   1 2 B(r) A(r) r A B A (r) B (r)   1 2

Example: BCNF Decomposition Drinkers(name, addr, beersLiked, manf, favBeer) FDs = name->addr, name -> favBeer, beersLiked->manf Pick BCNF violation name->addr. Close the left side: {name}+ = {name, addr, favBeer}. Decomposed relations: Drinkers1(name, addr, favBeer) Drinkers2(name, beersLiked, manf)

Example -- Continued We are not done; we need to check Drinkers1 and Drinkers2 for BCNF. Is Drinkers1 in BCNF ? For Drinkers1(name, addr, favBeer), relevant FD’s are name->addr and name->favBeer. Thus, {name} is the only key and Drinkers1 is in BCNF.

Example -- Continued For Drinkers2(name, beersLiked, manf), the only FD is beersLiked->manf, and the only key is {name, beersLiked}. Violation of BCNF ? beersLiked+ = {beersLiked, manf}, so we decompose Drinkers2 into: Drinkers3(beersLiked, manf) Drinkers4(name, beersLiked)

Example -- Concluded The resulting decomposition of Drinkers : Drinkers1(name, addr, favBeer) Drinkers3(beersLiked, manf) Drinkers4(name, beersLiked) Note: Drinkers1 tells us about drinkers, Drinkers3 tells us about beers, and Drinkers4 tells us the relationship between drinkers and the beers they like.

Summary of BCNF Decomposition Find a dependency that violates the BCNF condition: A , A , … A B , B , … B n 1 2 1 2 m Decompose: Continue until there are no BCNF violations left. Others A’s B’s Is there a 2-attribute relation that is not in BCNF ? R1 R2