More on Decompositions and Third Normal Form CIS 4301 Lecture Notes Lecture 11 - 2/16/2006.

Slides:



Advertisements
Similar presentations
CS 319: Theory of Databases
Advertisements

Schema Refinement: Normal Forms
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Lecture 21 CS 157 B Revision of Midterm3 Prof. Sin-Min Lee.
Normalization 1 Instructor: Mohamed Eltabakh Part II.
Normalization Decomposition techniques for ensuring: Lossless joins Dependency preservation Redundancy avoidance We will look at some normal forms: Boyce-Codd.
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.
Spring 2011 Instructor: Hassan Khosravi
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.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 6 A First Course in Database Systems.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 227 Database Systems I Design Theory for Relational Databases.
Instructor: Amol Deshpande  Data Models ◦ Conceptual representation of the data  Data Retrieval ◦ How to ask questions of the database.
Closure The closure of {B 1 …B k } under the set of FDs S, denoted by {B 1 …B k } +, is defined as follows: {B 1 …B k } + = {B | any relation satisfies.
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.
The principal problem that we encounter is redundancy, where a fact is repeated in more than one tuple. Most common cause: attempts to group into one relation.
Winter 2002Arthur Keller – CS 1804–1 Schedule Today: Jan. 15 (T) u Normal Forms, Multivalued Dependencies. u Read Sections Assignment 1 due. Jan.
Decomposition By Yuhung Chen CS157A Section 2 October
Multivalued Dependencies by Asmerom Tekeste. Normal Forms 1NF 2NF 3NF BCNF 4NF 5NF Functional dependencies Multivalued dependencies Join dependencies.
Multivalued Dependencies By David Wortham. Problem Introduction Assume a relation R (from the book): (credit Ullman and Widom) Assume a relation R (from.
Multivalued Dependencies. Intuition Redundancy: addresses, title repeated several times –because a star might have several addresses and stars in several.
MVDs: 1 Join Dependencies—Example Let r = A B C = A B |  | A C 1 a x 1 a 1 x 1 a y 1 b 1 y 1 b x 2 a 2 y 1 b y 2 b 2 a y 2 b y Observe: r =  AB r | 
Fall 2001Arthur Keller – CS 1804–1 Schedule Today Oct. 4 (TH) Functional Dependencies and Normalization. u Read Sections Project Part 1 due. Oct.
1 Lecture 7: Schema refinement: Normalisation
Chapter 14 Advanced Normalization Transparencies © Pearson Education Limited 1995, 2005.
Ch 7: Normalization-Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
Multi-valued Dependencies and Fourth Normal Form
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.
Copyright © Curt Hill Schema Refinement III 4 th NF and 5 th NF.
Chapter 8: Relational Database Design First Normal Form First Normal Form Functional Dependencies Functional Dependencies Decomposition Decomposition Boyce-Codd.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
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)
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.
BCNF & Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science.
Normal Forms through BCNF CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
Computing & Information Sciences Kansas State University Tuesday, 27 Feb 2007CIS 560: Database System Concepts Lecture 18 of 42 Tuesday, 27 February 2007.
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.
Third Normal Form (3NF) Zaki Malik October 23, 2008.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Design Process - Where are we?
Normalization.
Functional Dependencies and Relational Schema Design.
1 Multivalued Dependencies Fourth Normal Form Reasoning About FD’s + MVD’s.
Design Theory for RDB Normal Forms. Lu Chaojun, SJTU 2 Redundant because these info may be figured out by using FD s1  … What’s Bad Design? Redundancy.
3 Spring Chapter Normalization of Database Tables.
Multivalued Dependencies Fourth Normal Form Tony Palladino 157B.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.
Multivalued Dependencies and 4th NF CIS 4301 Lecture Notes Lecture /21/2006.
Lecture 17 4 th Normal Form Prof. Sin-Min Lee Department of Computer Science.
CS 338Database Design and Normal Forms9-1 Database Design and Normal Forms Lecture Topics Measuring the quality of a schema Schema design with normalization.
© 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.
Normal Forms Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems June 18, 2016 Some slide content courtesy of Susan Davidson.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
4NF & MULTIVALUED DEPENDENCY By Kristina Miguel. Review  Superkey – a set of attributes which will uniquely identify each tuple in a relation  Candidate.
Advanced Normalization
Schedule Today: Next After that Normal Forms. Section 3.6.
Schedule Today: Jan. 23 (wed) Week of Jan 28
3.1 Functional Dependencies
Module 5: Overview of Normalization
Multivalued Dependencies & Fourth Normal Form (4NF)
Mulitvalued Dependencies
Third Normal Form.
Multivalued Dependencies
Chapter 7a: Overview of Database Design -- Normalization
Presentation transcript:

More on Decompositions and Third Normal Form CIS 4301 Lecture Notes Lecture /16/2006

Lecture 11© CIS Spring Recovering Information Idea behind decomposition is that we can “join” two relations and get original data back Lossless join preservation What can go wrong? May not get all of the original tuples back May get “new” tuples which were not part of the original relation In both cases, loss of information Let’s find out why decomposition works

Lecture 11© CIS Spring Recovering Information R(A,B,C) FD: {B  C} is a BCNF violation Decomposition: R 1 (A,B) and R 2 (B,C) What are our options for keys? R 1 : A or A,B R 2 : B,C Does this decomposition allows us to recover all of (and only) the tuples of R?

Lecture 11© CIS Spring Test 1: Do We Get All Tuples Back? Let t be tuple of R: t=(a,b,c ) t projects as t 1 = (a,b) for R 1 t projects as t 2 = (b,c) for R 2 Since t 1 and t 2 agree on b value, it is always possible to get t = t 1 join t 2

Lecture 11© CIS Spring Test 2: Do We Get Only Tuples from R Back? What happens if we join R1 and R2? x= (a,b,e) Is x a tuple of R? YES! Since B  C holds. Why? abc dbe R t v ab R1R1 t be R2R2 v

Lecture 11© CIS Spring Third Normal Form (3NF) Occasionally, we encounter a relation and its dependencies that are not in BCNF but that one doesn’t want to decompose any further Ex.: Bookings(title,theater,city) (m,t,c) : movie with title m is currently being shown at theater t in city c FDs: theater  city title city  theater What are the candidate key(s) for Bookings ? Use augment. rule on theater  city to get theater,title  city,title Use augment. rule on title,city  theater to get title,city  theater,city,title {title, city} {theater, title}

Lecture 11© CIS Spring Decomposition with Problems FD: theater  city is a violation, theater is not a superkey theatercity R1 GuildMenlo Park ParkMenlo Park theatertitle R2 GuildThe Net ParkThe Net Tempted to decompose Bookings into R1(theater,city) F1: {theater  city} R2(theater,title) F2: {only trivial} Problem! What happened to original FD title city  theater ? permissible snapshots

Lecture 11© CIS Spring Joined Bookings Violates FD In the joined relation, the tuples violate the FD title city  theater theatercity R1 GuildMenlo Park ParkMenlo Park theatertitle R2 GuildThe Net ParkThe Net theatertitle R1R2 GuildThe Net ParkThe Net city Menlo Park

Lecture 11© CIS Spring Solution Relax our definition of BCNF slightly allow occasional relational schema that cannot be decomposed further without losing the ability to check each FD within one relation Relaxed condition is called 3NF Definition: A relation is in 3NF if: whenever A 1 A 2 … A n  B is a nontrivial dependency, either {A 1, A 2, …, A n } is a superkey, or B is a member of some key Original Bookings in 3NF

Lecture 11© CIS Spring Summary What’s so great about 3NF? We can always decompose a a relation schema in a way that does not lose information, into schemas that are in 3NF In addition: allow ALL functional dependencies to be checked! HOWEVER: when these relations are left in 3NF (not in BCNF), there will be some redundancy left in schema

Lecture 11© CIS Spring Multivalued Dependencies There are schemas that are in BCNF that do not seem to be sufficiently normalized namestreet Stars citytitleyear C. Fisher 123 Maple Str. 5 Locust Ln. 123 Maple Str. 5 Locust Ln. 123 Maple Str. 5 Locust Ln.C. Fisher Hollywood Malibu Hollywood Malibu Hollywood Malibu Star Wars1977 Star Wars1977 Empire Strikes Back1980 Empire Strikes Back1980 Return of the Jedi1983 Return of the Jedi1983

Lecture 11© CIS Spring Attribute Independence No reason to associate address with one movie and not another When we repeat address and movie facts in all combinations, there is obvious redundancy However, NO BCNF violation in Stars relation There are no non-trivial FD’s at all, all five attributes form the only superkey Why?

Lecture 11© CIS Spring Definition Definition: Multivalued dependency (MVD): A 1 A 2 …A n  B 1 B 2 …B m holds for relation R if: For all tuples t, u in R If t[A 1 A 2...A n ] = u[A 1 A 2...A n ], then there exists a v in R such that: (1) v[A 1 A 2...A n ] = t[A 1 A 2...A n ] = u[A 1 A 2...A n ] (2) v[B 1 B 2 …B m ] = t[B 1 B 2 …B m ] (3) v[C 1 C 2 …C k ] = u[C 1 C 2 …C k ], where C 1 C 2 …C k is all attributes in R except (A 1 A 2...A n  B 1 B 2 …B m )

Lecture 11© CIS Spring Pictorially Speaking... An MVD guarantees v exists The existence of a fourth tuple w is implied by interchanging t and u t u A’sB’sOthers v w

Lecture 11© CIS Spring Example: name  street city namestreet Stars citytitleyear C. Fisher 123 Maple Str. 5 Locust Ln. Hollywood Malibu Star Wars1977 Empire Strikes Back1980 Empire Strikes Back1980 C. Fisher 5 Locust Ln. 123 Maple Str. 5 Locust Ln.C. Fisher Malibu Hollywood Malibu Star Wars1977 Return of the Jedi1983 Return of the Jedi1983 t u v

Lecture 11© CIS Spring Example: name  street city namestreet Stars citytitleyear C. Fisher 123 Maple Str. 5 Locust Ln. 123 Maple Str. 5 Locust Ln. Hollywood Malibu Hollywood Malibu Star Wars1977 Star Wars1977 Empire Strikes Back1980 Empire Strikes Back1980 C. Fisher123 Maple Str. 5 Locust Ln.C. Fisher Hollywood Malibu Return of the Jedi1983 Return of the Jedi1983 u t w v