Lossless Decomposition By Chi-Shu Ho For CS157A Prof. Sin-Min Lee.

Slides:



Advertisements
Similar presentations
primary key constraint foreign key constraint
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Lossless Decomposition Anannya Sengupta CS 157A Prof. Sin-Min Lee.
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.
LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Dr. Kalpakis CMSC 461, Database Management Systems URL: Relational Database Design.
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.
C.1 Appendix C: Advanced Relational Database Design Reasoning with MVDs Higher normal forms Join dependencies and PJNF DKNF.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Appendix B: Advanced.
 1 CS 728 Advanced Database Systems Chapter 15 Database Design Theory: Normalization Algorithms.
©Silberschatz, Korth and Sudarshan Relational Database Design First Normal Form Pitfalls in Relational Database Design Functional Dependencies Decomposition.
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.
Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
Lossless Decomposition Elias Aseged SE 157B - DB 2.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Relational Database Design - part 2 - Database Management Systems I Alex Coman,
DATABASE DESIGN Functional Dependencies. Overview n Functional Dependencies n Normalization –Functional dependencies –Normal forms.
Lecture #3 Functional Dependencies Normalization Relational Algebra Thursday, October 12, 2000.
Normal Form Design addendum by C. Zaniolo. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Normal Form Design Compute the canonical cover.
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.
Functional Dependencies (Part 3) Presented by Nash Raghavan All page numbers are in reference to Database System Concepts (5 th Edition)
Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Decomposition By Yuhung Chen CS157A Section 2 October
1 Schema Refinement and Normal Forms Chapter 19 Raghu Ramakrishnan and J. Gehrke (second text book) In Course Pick-up box tomorrow.
Boyce-Codd NF & Lossless Decomposition Professor Sin-Min Lee.
Department of Computer Science and Engineering, HKUST Slide 1 7. Relational Database Design.
Boyce-Codd Normal Form By: Thanh Truong. Boyce-Codd Normal Form Eliminates all redundancy that can be discovered by functional dependencies But, we can.
Functional Dependencies and Relational Schema Design.
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.
Chapter 7: Relational Database Design. 7.2Unite International CollegeDatabase Management Systems Chapter 7: Relational Database Design Features of Good.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
FUNCTIONAL DEPENDENCIES. Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant Information.
Chapter 7: Relational Database Design. 7.2Unite International CollegeDatabase Management Systems Chapter 7: Relational Database Design Features of Good.
1 Schema Design & Refinement (aka Normalization).
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design Pitfalls in.
Relational Database Design by Relational Database Design by Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
©Silberschatz, Korth and SudarshanC.1Database System Concepts, 5 th Ed. Appendix C: Advanced Relational Database Design.
Chapter 8: Relational Database Design First Normal Form First Normal Form Functional Dependencies Functional Dependencies Decomposition Decomposition Boyce-Codd.
Lecture 09: Functional Dependencies. Outline Functional dependencies (3.4) Rules about FDs (3.5) Design of a Relational schema (3.6)
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.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
Logical Database Design (1 of 3) John Ortiz Lecture 6Logical Database Design (1)2 Introduction  The logical design is a process of refining DB schema.
Christoph F. Eick: Functional Dependencies, BCNF, and Normalization 1 Functional Dependencies, BCNF and Normalization.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Functional Dependencies. Outline Functional dependencies (3.4) Rules about FDs (3.5) Design of a Relational schema (3.6)
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Appendix B: Advanced.
1 Lecture 10: Database Design Wednesday, January 26, 2005.
Functional Dependencies and Relational Schema Design.
1 Lecture 10: Database Design and Relational Algebra Monday, October 20, 2003.
CS542 1 Schema Refinement Chapter 19 (part 1) Functional Dependencies.
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
1 Lecture 9: Database Design Wednesday, January 25, 2006.
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
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.
Module 5: Overview of Database Design -- Normalization
Relational Database Design by Dr. S. Sridhar, Ph. D
Relational Database Design
Functional Dependencies and Normalization
Functional Dependencies and Normalization
Functional Dependencies and Normalization
Presentation transcript:

Lossless Decomposition By Chi-Shu Ho For CS157A Prof. Sin-Min Lee

Decomposition  Goal: Eliminate redundancy by decomposing a relation into several relations in a higher normal form.  It is important to check that a decomposition does not introduce new problems. -- A good decomposition allows us to recover the original relation

Decompositions in General Let R be a relation with attributes A 1,A 2,…A n Create two relations R1 and R2 with attributes B 1, B 2,…B m C 1,C 2,…C i Such that: B 1, B 2,…B m ∪ C 1,C 2,…C i = A 1,A 2,…A N And R1 is the projection of R on B 1, B 2,…B m R2 is the projection of R on C 1,C 2,…C i

Problems with Decomposition Some queries become more expensive Given instances of the decomposed relations, we may not be able to reconstruct the corresponding instance of the original relation – information loss.

Certain Decomposition May Cause Problem NamePriceCategory Gizmo19.99Gadget OneClick24.99Camera DoubleClick29.99Camera PriceCategory 19.99Gadget 24.99Camera 29.99Camera NameCategory GizmoGadget OneClickCamera DoubleClickCamera R R1R2

NamePriceCategory Gizmo19.99Gadget OneClick24.99Camera OneClick29.99Camera DoubleClick29.99Camera DoubleClick29.99Camera R’ NamePriceCategory Gizmo19.99Gadget OneClick24.99Camera DoubleClick29.99Camera R

Lossy Decomposition EmployeeProjectBranch BrownMarsL.A. GreenJupiterSan Jose GreenVenusSan Jose HoskinsSaturnSan Jose HoskinsVenusSan Jose Functional dependencies: Employee Branch, Project Branch T

Lossy Decomposition Decomposition of the previous relation EmployeeBranch BrownL.A GreenSan Jose HoskinsSan Jose ProjectBranch MarsL.A. JupiterSan Jose SaturnSan Jose VenusSan Jose T1T2

Lossy Decomposition After Natural Join EmployeeProjectBranch BrownMarsL.A. GreenJupiterSan Jose GreenVenusSan Jose HoskinsSaturnSan Jose HoskinsVenusSan Jose GreenSaturnSan Jose HoskinsJupiterSan Jose EmployeeProjectBranch BrownMarsL.A. GreenJupiterSan Jose GreenVenusSan Jose HoskinsSaturnSan Jose HoskinsVenusSan Jose Original Relation The result is different from the original relation: the information can not be reconstructed.

Lossless Decompostion A decomposition is lossless if we can recover: R(A, B, C) Decompose R1(A, B) R2(A, C) Recover R’(A, B, C) R’ = R

What is lossless decomposition?  The decomposition of a relation R on X 1 and X 2 is lossless if the join of the projections of R on X 1 and X 2 is equal to R itself (that is, not containing false tuples).

Lossless Decomposition Property  The decomposition of R into X and Y is lossless with respect to F if and only if the closure of F contains either: – X ∩ Y (X intersect Y)  X, that is: all attributes common to both X and Y functionally determine ALL the attributes in X OR – X ∩ Y (X intersect Y)  Y, that is: all attributes common to both X and Y functionally determine ALL the attributes in Y

Armstrong’s Axioms X, Y, Z are sets of attributes 1. Reflexivity: If X  Y, then X  Y 2. Augmentation: If X  Y, then XZ  YZ for any Z 3. Transitivity: If X  Y and Y  Z, then X  Z 4. Union: If X  Y and X  Z, then X  YZ 5. Decomposition: If X  YZ, then X  Y and X  Z

Example of Lossless Decomposition GIVEN: LENDINGSCHEME=(BRANCHNAME, ASSETS, BRANCHCITY, LOANNUMBER, CUSTOMERNAME, AMOUNT) REQUIRED FD'S: l BRANCHNAME  ASSETS BRANCHCITY l LOANNUMBER  AMOUNT BRANCHNAME DECOMPOSE LENDINGSCHEME INTO: 1. BRANCHSCHEME=(BRANCHNAME, ASSETS, BRANCHCITY) 2. BORROWSCHEME=(BRANCHNAME, LOANNUMBER, CUSTOMERNAME, AMOUNT)

Example of Lossless Decomposition SHOW THAT THE DECOMPOSITION IS A LOSSLESS DECOMPOSITION 1.USE AUGMENTATION RULE ON FIRST FD TO OBTAIN: BRANCHNAME  BRANCHNAME ASSETS BRANCHCITY 2.INTERSECTION OF BRANCHSCHEME AND BORROWSCHEME IS BRANCHNAME 3.BRANCHNAME  BRANCHSCHEME 4.SO, INITIAL DECOMPOSITION IS A LOSSLESS

Example 2 GIVEN: BORROWSCHEME=(BRANCHNAME, LOANNUMBER, CUSTOMERNAME, AMOUNT) REQUIRED FD'S: l LOANNUMBER  AMOUNT BRANCHNAME DECOMPOSE LENDINGSCHEME INTO: 1. LOAN-INFO-SCHEME=(BRANCHNAME, LOANNUMBER, AMOUNT) 2. CUSTOMER-LOAN-SCHEME=(LOANNUMBER, CUSTOMERNAME)

Example 2 (con’t) SHOW THAT THE DECOMPOSITION IS A LOSSLESS DECOMPOSITION 1.USE AUGMENTATION RULE ON FD TO OBTAIN: LOANNUMBER  LOANNUMBER AMOUNT BRANCHNAME 2.INTERSECTION OF LOAN-INFO-SCHEME AND CUSTOMER-LOAN-SCHEME IS LOANNUMBER 3.LOANNUMBER  LOAN-INFO-SCHEME 4.SO, INITIAL DECOMPOSITION IS A LOSSLESS

Example R1 (A1, A2, A3, A5) R2 (A1, A3, A4) R3 (A4, A5) FD1: A1  A3 A5 FD2: A5  A1 A4 FD3: A3 A4  A2

A1 A2 A3 A4 A5 R1 a(1) a(2) a(3) b(1,4) a(5) R2 a(1) b(2,2) a(3) a(4) b(2,5) R3 b(3,1) b(3,2) b(3,3) a(4) a(5) Example (con’t)

By FD1: A1  A3 A5 A1 A2 A3 A4 A5 R1 a(1) a(2) a(3) b(1,4) a(5) R2 a(1) b(2,2) a(3) a(4) b(2,5) R3 b(3,1) b(3,2) b(3,3) a(4) a(5) Example (con’t)

By FD1: A1  A3 A5 we have a new result table A1 A2 A3 A4 A5 R1 a(1) a(2) a(3) b(1,4) a(5) R2 a(1) b(2,2) a(3) a(4) a(5) R3 b(3,1) b(3,2) b(3,3) a(4) a(5) Example (con’t)

By FD2: A5  A1 A4 A1 A2 A3 A4 A5 R1 a(1) a(2) a(3) b(1,4) a(5) R2 a(1) b(2,2) a(3) a(4) a(5) R3 b(3,1) b(3,2) b(3,3) a(4) a(5) Example (con’t)

By FD2: A5  A1 A4 we have a new result table A1 A2 A3 A4 A5 R1 a(1) a(2) a(3) a(4) a(5) R2 a(1) b(2,2) a(3) a(4) a(5) R3 a(1) b(3,2) b(3,3) a(4) a(5) Example (con’t)

Conclusions Decompositions should always be lossless: -- Lossless decomposition ensure that the information in the original relation can be accurately reconstructed based on the information represented in the decomposed relations.