Lossless Decomposition Anannya Sengupta CS 157A 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.
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.
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.
Manipulating Functional Dependencies Zaki Malik September 30, 2008.
METU Department of Computer Eng Ceng 302 Introduction to DBMS Further Dependencies by Pinar Senkul resources: mostly froom Elmasri, Navathe and other books.
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.
Relational Normalization Theory. Limitations of E-R Designs Provides a set of guidelines, does not result in a unique database schema Does not provide.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Appendix B: Advanced.
©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 (2) Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science San Jose State University.
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.
Normal Form Design addendum by C. Zaniolo. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Normal Form Design Compute the canonical cover.
Functional Dependencies (Part 3) Presented by Nash Raghavan All page numbers are in reference to Database System Concepts (5 th Edition)
Lossless Decomposition By Chi-Shu Ho For CS157A Prof. Sin-Min Lee.
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.
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.
Chapter 11 Relational Database Design Algorithms and Further Dependencies Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Chapter 8 Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Chapter 8: Relational Database Design First Normal Form First Normal Form Functional Dependencies Functional Dependencies Decomposition Decomposition Boyce-Codd.
Relational Database Design
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
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.
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.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide DESIGNING A SET OF RELATIONS (2) Goals: Lossless join property (a must). Dependency.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 7: Relational.
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.
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.
Computing & Information Sciences Kansas State University Tuesday, 27 Feb 2007CIS 560: Database System Concepts Lecture 18 of 42 Tuesday, 27 February 2007.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 11 Relational Database Design Algorithms and Further Dependencies.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
Ihr Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Ihr Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Chapter 10 Functional Dependencies and Normalization for Relational Databases.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
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 Chapter 2: Introduction.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Appendix B: Advanced.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Relational Database Design Algorithms and Further Dependencies.
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.
Functional Dependencies Quiz. Project Relation Attributes project name – pname start date – start budget customer name – cname customer phone – cphone.
Computing & Information Sciences Kansas State University Friday, 03 Oct 2007CIS 560: Database System Concepts Lecture 16 of 42 Wednesday, 03 October 2007.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Module 5: Overview of Database Design -- Normalization
Relational Database Design by Dr. S. Sridhar, Ph. D
Chapter 8: Relational Database Design
Chapter 7: Relational Database Design
Chapter 7: Relational Database Design
Appendix C: Advanced Normalization Theory
Normal Form: 4 & 5.
Appendix C: Advanced Relational Database Design
Chapter 28: Advanced Relational Database Design
Presentation transcript:

Lossless Decomposition Anannya Sengupta CS 157A Prof. Sin-Min Lee

Definition of Decomposition Let R be a relation schema A set of relation schemas { R1, R2, …, Rn } is a decomposition of R if  R = R1 U R2 U …..U Rn  each Ri is a subset of R ( for i = 1,2 …,n)

Example of Decomposition For relation R(x,y,z) there can be 2 subsets: R1(x,z) and R2(y,z) If we union R1 and R2, we get R R = R1 U R2

Goal of Decomposition Eliminate redundancy by decomposing a relation into several relations in a higher normal form. It is important to check that a decomposition does not lead to bad design

Problem with Decomposition Given instances of the decomposed relations, we may not be able to reconstruct the corresponding instance of the original relation – information loss

Example : Problem with Decomposition Model NamePriceCategory a11100Canon s20200Nikon a70150Canon R Model NameCategory a11Canon s20Nikon a70Canon PriceCategory 100Canon 200Nikon 150Canon R1R2

Example : Problem with Decomposition R1 U R2 Model NamePriceCategory a11100Canon a11150Canon s20200Nikon a70100Canon a70150Canon Model NamePriceCategory a11100Canon s20200Nikon a70150Canon R

Lossy decomposition In previous example, additional tuples are obtained along with original tuples Although there are more tuples, this leads to less information Due to the loss of information, decomposition for previous example is called lossy decomposition or lossy-join decomposition

Lossy decomposition (more example) EmployeeProjectBranch BrownMarsL.A. GreenJupiterSan Jose GreenVenusSan Jose HoskinsSaturnSan Jose HoskinsVenusSan Jose T Functional dependencies: Employee Branch, Project Branch

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 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 After Natural Join Original Relation After Natural Join, we get two extra tuples. Thus, there is loss of information.

Lossless Decomposition A decomposition {R1, R2, …, Rn} of a relation R is called a lossless decomposition for R if the natural join of R1, R2, …, Rn produces exactly the relation R.

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

Lossless Decomposition Property R : relation F : set of functional dependencies on R X,Y : decomposition of R Decomposition is lossles if :  X ∩ Y  X, that is: all attributes common to both X and Y functionally determine ALL the attributes in X OR  X ∩ Y  Y, that is: all attributes common to both X and Y functionally determine ALL the attributes in Y

Lossless Decomposition Property In other words, if X ∩ Y forms a superkey of either X or Y, the decomposition of R is a lossless decomposition

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 : Lossless Decomposition Given: Lending-schema = (branch-name, branch-city, assets, customer-name, loan-number, amount) Required FD’s: branch-namebranch-city assets loan-numberamount branch-name Decompose Lending-schema into two schemas: Branch-schema = (branch-name, branch-city, assets) Loan-info-schema = (branch-name, customer-name, loan-number, amount)

Example : Lossless Decomposition Show that decomposition is Lossless Decomposition  Since branch-namebranch-city assets, the augmentation rule for FD implies that: branch-namebranch-name branch-city assets  Since Branch-schema ∩ Loan-info-schema = {branch- name} Thus, this decomposition is Lossless decomposition

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

Example (con’t) 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) 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)

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.

References Fundamentals of Database Systems Fourth Edition Elmasri, Navathe Database System Concepts Fourth Edition Silberschatz, Korth, Sudarshan