Decomposition Liangsheng Deng Section 2 11/15/2005.

Slides:



Advertisements
Similar presentations
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C3.
Advertisements

Schema Refinement: Normal Forms
Schema Refinement: Canonical/minimal Covers
Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources.
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.
Manipulating Functional Dependencies Zaki Malik September 30, 2008.
Chapter 11 Functional Dependencies. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.11-2 Topics in this Chapter Basic Definitions Trivial.
Temple University – CIS Dept. CIS616– Principles of Data Management V. Megalooikonomou Functional Dependencies (based on notes by Silberchatz,Korth, and.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications Lecture #16: Schema Refinement & Normalization - Functional Dependencies.
Topics to be discusses Functional Dependency Key
7.1 Chapter 7: Relational Database Design. 7.2 Chapter 7: Relational Database Design Features of Good Relational Design Atomic Domains and First Normal.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
Normalization DB Tuning CS186 Final Review Session.
Normalization DB Tuning CS186 Final Review Session.
Multivalued Dependency Prepared by Tomasz Kaciak CS157A.
FDImplication: 1 Functional Dependencies (FDs) Let r(R) be a relation and let t  r, then the restriction of t to X  R, written t[X], is the projection.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Relational Database Design - part 2 - Database Management Systems I Alex Coman,
CMSC424: Database Design Instructor: Amol Deshpande
Design Theory.
1 CMSC424, Spring 2005 CMSC424: Database Design Lecture 9.
Decomposition By Yuhung Chen CS157A Section 2 October
Cs3431 Normalization. cs3431 Why Normalization? To remove potential redundancy in design Redundancy causes several anomalies: insert, delete and update.
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C3.
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 Triggers: Correction. 2 Mutating Tables (Explanation) The problems with mutating tables are mainly with FOR EACH ROW triggers STATEMENT triggers can.
Chapter 8: Relational Database Design First Normal Form First Normal Form Functional Dependencies Functional Dependencies Decomposition Decomposition Boyce-Codd.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
Functional Dependencies Prof. Yin-Fu Huang CSIE, NYUST Chapter 11.
Computing & Information Sciences Kansas State University Monday, 13 Oct 2008CIS 560: Database System Concepts Lecture 18 of 42 Monday, 13 October 2008.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
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 An example: loan-info= Observe: tuples with the same value for lno will always have the same value for amt We write: lno  amt.
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.
BCNF & Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science.
Computing & Information Sciences Kansas State University Tuesday, 27 Feb 2007CIS 560: Database System Concepts Lecture 18 of 42 Tuesday, 27 February 2007.
1 Lecture 6: Schema refinement: Functional dependencies
Functional Dependencies. FarkasCSCE 5202 Reading and Exercises Database Systems- The Complete Book: Chapter 3.1, 3.2, 3.3., 3.4 Following lecture slides.
CHAPTER 19 SCHEMA, REFINEMENT AND NORMAL FORMS
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
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.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
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.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications Lecture #16: Schema Refinement & Normalization - Functional Dependencies.
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.
Lecture 17 4 th Normal Form Prof. Sin-Min Lee Department of Computer Science.
CS542 1 Schema Refinement Chapter 19 (part 1) Functional Dependencies.
Databases 1 Sixth lecture. 2 Functional Dependencies X -> A is an assertion about a relation R that whenever two tuples of R agree on all the attributes.
© 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.
Computing & Information Sciences Kansas State University Friday, 03 Oct 2007CIS 560: Database System Concepts Lecture 16 of 42 Wednesday, 03 October 2007.
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.
Relational Database Design
Handout 4 Functional Dependencies
Schema Refinement & Normalization Theory
Functional Dependencies and Normalization
Relational Data Base Design in Practice
Normalization cs3431.
Some slides are from Dr. Sara Cohen
Relational Database Theory
CS4222 Principles of Database System
Presentation transcript:

Decomposition Liangsheng Deng Section 2 11/15/2005

Recall Functional Dependencies  A->B holds iff for any pairs of tuples t1 and t2 such that if t1[A] = t2[A], then t1[B] = t2[B].  Armstong’s axioms:  Reflexivity rule. If a is a set of attributes and b is a subset of a, then a->b holds.  Augmentation rule. If a->b holds and c is a set of attributes, then ac->bc holds.  Transitivity rule. If a->b holds and b->c holds, then a->c holds.

Closure of a Set of FD  Given f, a set of FD of a relational schema, we can use Armstrong axioms to derive other possible FD implied by f.  The closure of f is the set of all FD implied by f.  Determine whether S, a set of attributes, is a superkey by computing the closure of S.

Closure Computing Example  Given R(A, B, C, D, E, H) with FD1. BD->A, FD2. AC->H, FD3. D->C, FD4. E->D. Is BE a superkey of R? {BE}+ = {BDE} because E->D {BE}+ = {BCDE} because D->C {BE}+ = {ABCDE} because BD->A {BE}+ = {ABCDEH} because AC->H BE is a superkey of R.

Lossless Decomposition The purpose of using lossless decomposition:  Reduce unnecessary redundancy.  Retrieve information efficiently How do we decide a decomposition is a lossless decomposition?  Let R be a relation schema.  Let F be a set of functional dependencies on R.  Let R1 and R2 form a decomposition of R. The decomposition is a lossless-join decomposition of R if at least one of the following functional dependencies holds. R1 ∩ R2 -> R1 or R2 ∩ R1 -> R2

Lossless Decomposition Testing (1)  Given R1(A, B), R2(A, C, D) and F = {A->C; D->B; AC->B}. Is the join of R1 and R2 lossless?   R1 ∩ R2 = {A} If we can prove A->B, then the answer is yes. If we can prove A->B, then the answer is yes.Proof: A->AC because A->C A->B because A->AC and AC->B So, it is a lossless cecomposition.

Lossless Decomposition Testing (2)  To test whether  To test whether R1 ∩ R2 -> R1 or R2, we can test whether R1 ∩ R2 is a superkey of R1 or R2 by computing the closure of R1 ∩ R2.   Same question in the previous slide.   {R1 ∩ R2}+ = {A}+, {A}+ = {AC} because A->C {A}+ = {ABC} because AC->B Conclusion: A is a superkey of R1. Therefore, it is a lossless decomposition.

Lossless Decomposition Testing (3)  For the case of decomposition of a schema into more than 2 schemas, we can use the chase matrix algorithm.  For example, F = {A->C, B->C, C->D, DE->C, CE->A}, R1(AD), R2(AB), R3(BE), R4(CDE) and R5(AE). ABCDE R1(AD)a1b12b13a4b15 R2(AB)a1a2b23b24b25 R3(BE)b31a2b33b34a5 R4(CDE)b41b42a3a4a5 R5(AE)a1b52b53b54a5

Lossless Decomposition Testing (3) Cont. A->C, we get ABCDE R1(AD)a1b12b13a4b15 R2(AB)a1a2b13b24b25 R3(BE)b31a2b33b34a5 R4(CDE)b41b42a3a4a5 R5(AE)a1b52b13b54a5 B->C, we get ABCDE R1(AD)a1b12b13a4b15 R2(AB)a1a2b13b24b25 R3(BE)b31a2b13b34a5 R4(CDE)b41b42a3a4a5 R5(AE)a1b52b13b54a5

Lossless Decomposition Testing (3) Cont. C->D, we get ABCDE R1(AD)a1b12b13a4b15 R2(AB)a1a2b13a4b25 R3(BE)b31a2b13a4a5 R4(CDE)b41b42a3a4a5 R5(AE)a1b52b13a4a5 DE->C ABCDE R1(AD)a1b12b13a4b15 R2(AB)a1a2b13a4b25 R3(BE)b31a2a3a4a5 R4(CDE)b41b42a3a4a5 R5(AE)a1b52a3a4a5

Lossless Decomposition Testing (3) Cont. CE->A ABCDE R1(AD)a1b12b13a4b15 R2(AB)a1a2b23a4b25 R3(BE)a1a2a3a4a5 R4(CDE)a1b42a3a4a5 R5(AE)a1b52a3a4a5 The third tuple has a1, a2, a3,a4 and a5, so it is a lossless decomposition. it is a lossless decomposition.

Dependency Preservation Let F be a set of functional dependencies on schema R. Let F be a set of functional dependencies on schema R. Let {R1,R2,…Rn} be a decomposition of R. Let {R1,R2,…Rn} be a decomposition of R. The restriction of F to Ri is the set of all functional dependencies in F+ that include only attributes of Ri. The restriction of F to Ri is the set of all functional dependencies in F+ that include only attributes of Ri. Functional dependencies in a restriction can be tested in one relation, as they involve attributes in one relation schema. Functional dependencies in a restriction can be tested in one relation, as they involve attributes in one relation schema.

Dependency Preservation Cont.  The set of restrictions F1,F2,…Fn is the set of dependencies that can be checked efficiently.  We need to know whether testing only the restrictions is sufficient.  Let F’ = F1 U F2 U….Fn.  F’ is a set of functional dependencies on schema R, but in general, F’ != F.

Dependency Preservation Cont.  A decomposition having the property that is a dependency-preserving decomposition.

Dependency Preservation Cont. An Easier Way To Test For Dependency Preservation. Rather than compute F+ and F’+, and see whether they are equal, we can do this: Rather than compute F+ and F’+, and see whether they are equal, we can do this: Find F – F’, the functional dependencies not checkable in one relation. See whether this set is obtainable from F' by using Armstrong's Axioms. This should take a great deal less work, as we have (usually) just a few functional dependencies to work on.

Dependency Preservation Cont.  For example, given F={AB->C, C->A}, R1(AC) and R2(BC).  F’ = {C->A}. F – F’ = {AB->C}. AB->C can not be derived from F’. So, it is not a dependency-preserving decomposition.

Reference al/notes/Chapter7/node1.html al/notes/Chapter7/node1.html