Relational Normalization Theory (supplemental material)



Similar documents
Databases -Normalization III. (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31

Database Design and Normalization

normalisation Goals: Suppose we have a db scheme: is it good? define precise notions of the qualities of a relational database scheme

Lecture Notes on Database Normalization

Database Design and Normal Forms

Quiz 3: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354

Database Management Systems. Redundancy and Other Problems. Redundancy

Database Design and Normalization

COSC344 Database Theory and Applications. Lecture 9 Normalisation. COSC344 Lecture 9 1

Relational Database Design

Functional Dependencies and Normalization

Functional Dependencies and Finding a Minimal Cover

Theory of Relational Database Design and Normalization

CS143 Notes: Normalization Theory

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 5: Normalization II; Database design case studies. September 26, 2005

Chapter 7: Relational Database Design

Design of Relational Database Schemas

Introduction Decomposition Simple Synthesis Bernstein Synthesis and Beyond. 6. Normalization. Stéphane Bressan. January 28, 2015

Theory behind Normalization & DB Design. Satisfiability: Does an FD hold? Lecture 12

Limitations of E-R Designs. Relational Normalization Theory. Redundancy and Other Problems. Redundancy. Anomalies. Example

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

Objectives of Database Design Functional Dependencies 1st Normal Form Decomposition Boyce-Codd Normal Form 3rd Normal Form Multivalue Dependencies

Week 11: Normal Forms. Logical Database Design. Normal Forms and Normalization. Examples of Redundancy

Chapter 10. Functional Dependencies and Normalization for Relational Databases

Schema Refinement, Functional Dependencies, Normalization

Schema Refinement and Normalization

How To Find Out What A Key Is In A Database Engine

Introduction to Database Systems. Normalization

Schema Design and Normal Forms Sid Name Level Rating Wage Hours

Relational Database Design: FD s & BCNF

Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010

Advanced Relational Database Design

Relational Database Design Theory

Chapter 7: Relational Database Design

Chapter 8. Database Design II: Relational Normalization Theory

Limitations of DB Design Processes

Why Is This Important? Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) Example (Contd.)

Chapter 10. Functional Dependencies and Normalization for Relational Databases. Copyright 2007 Ramez Elmasri and Shamkant B.

Normalisation. Why normalise? To improve (simplify) database design in order to. Avoid update problems Avoid redundancy Simplify update operations

Database Constraints and Design

Relational Normalization: Contents. Relational Database Design: Rationale. Relational Database Design. Motivation

An Algorithmic Approach to Database Normalization

Normalization of database model. Pazmany Peter Catholic University 2005 Zoltan Fodroczi

Theory of Relational Database Design and Normalization

6.830 Lecture PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization

Introduction to Database Systems. Chapter 4 Normal Forms in the Relational Model. Chapter 4 Normal Forms

Chapter 10 Functional Dependencies and Normalization for Relational Databases

Functional Dependency and Normalization for Relational Databases

Normalization. CIS 331: Introduction to Database Systems

Design Theory for Relational Databases: Functional Dependencies and Normalization

Database Management System

CSCI-GA Database Systems Lecture 7: Schema Refinement and Normalization

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen

Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina

RELATIONAL DATABASE DESIGN

DATABASE DESIGN: NORMALIZATION NOTE & EXERCISES (Up to 3NF)

Database Sample Examination

Functional Dependencies

Boyce-Codd Normal Form

Lecture 2 Normalization

A Web-Based Environment for Learning Normalization of Relational Database Schemata

Normalization in Database Design

Normalization for Relational DBs

CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES

Department of Computer Science 2015/16

DATABASE NORMALIZATION

Boolean Algebra (cont d) UNIT 3 BOOLEAN ALGEBRA (CONT D) Guidelines for Multiplying Out and Factoring. Objectives. Iris Hui-Ru Jiang Spring 2010

Graham Kemp (telephone , room 6475 EDIT) The examiner will visit the exam room at 15:00 and 17:00.

TYPICAL QUESTIONS & ANSWERS

SQL DDL. DBS Database Systems Designing Relational Databases. Inclusion Constraints. Key Constraints

Database Systems Concepts, Languages and Architectures

Announcements. SQL is hot! Facebook. Goal. Database Design Process. IT420: Database Management and Organization. Normalization (Chapter 3)

Unit 3.1. Normalisation 1 - V Normalisation 1. Dr Gordon Russell, Napier University

The class slides, your notes, and the sample problem that we worked in class may be helpful for reference.

Normal forms and normalization

Section The given line has equations. x = 3 + t(13 3) = t, y = 2 + t(3 + 2) = 2 + 5t, z = 7 + t( 8 7) = 7 15t.

DATABASE SYSTEMS. Chapter 7 Normalisation

Objectives, outcomes, and key concepts. Objectives: give an overview of the normal forms and their benefits and problems.

RESULTANT AND DISCRIMINANT OF POLYNOMIALS

3. Database Design Functional Dependency Introduction Value in design Initial state Aims

The University of British Columbia

MCQs~Databases~Relational Model and Normalization

Normalization of Database

Normalisation 1. Chapter 4.1 V4.0. Napier University

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.

Determination of the normalization level of database schemas through equivalence classes of attributes

Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks]

Chapter 6. Database Tables & Normalization. The Need for Normalization. Database Tables & Normalization

Normalization Theory for XML

BCA. Database Management System

A. TRUE-FALSE: GROUP 2 PRACTICE EXAMPLES FOR THE REVIEW QUIZ:

Unique column combinations

Production Supervision Incorporated With Network Technology-A Solution For Controlling In-Process Inventory

Future Trends in Airline Pricing, Yield. March 13, 2013

Algebraic Properties and Proofs

Teaching Database Modeling and Design: Areas of Confusion and Helpful Hints

Transcription:

Relational Normalization Theory (supplemental material) CSE 532, Theory of Database Systems Stony Brook University http://www.cs.stonybrook.edu/~cse532

2 Quiz 8 Consider a schema S with functional dependencies: {A BC, C FG, E HG, G A}. (a) Compute the attribute closure of A with respect to S. ABCFG (b) Suppose we decompose S so that one of the subrelations, say called R, contains attributes AFE only. Find a projection of the functional dependencies in S on R (i.e., find the functional dependencies between attributes AFE). {A F, E AF} or {A F, E A, E F} or {A F, E A} (c) Is R in BCNF? No, A is not a superkey. Use one cycle of the BCNF decomposition algorithm to obtain two subrelations, and check BCNF cond. R1={AF,A F} and R2={EA,E A}. They are in BCNF.

Quiz 8 (cont.) {A BC, C FG, E HG, G A}. Decomposition: R1={AF,A F} and R2={EA,E A}. (d) Show that your decomposition is lossless. {AF} {EA} = {A}, which is a key of R1. (e) Is your decomposition dependency preserving? Yes, because each of the FDs of R is entailed by FDs of R1 and R2. (f) Is R in 3NF? Explain. No, F is not part of a key. Use 3NF decomposition algorithm to obtain subrelations, and answer whether they are in 3NF. Obtain same R1={AF,A F} and R2={EA,E A}. They are in 3NF. 3

Quiz 9 Consider the following functional dependencies over the attribute set BCGHMVWY: W V WY BV WC V V B BG M BV Y BYH V M W Y H CY W Find a minimal cover. Decompose into lossless 3NF. Check if all the resulting relations are in BCNF. If not, decompose it into a lossless BCNF. 4

Quiz 9 W V WY BV WC V V B BG M BV Y BYH V M W Y H CY W Minimal cover: 1. Split WY BV into WY B and WY V. 5

Quiz 9 W V WY BV WC V V B BG M BV Y BYH V M W Y H CY W Minimal cover: 1. Split WY BV into WY B and WY V. 2. Since W V and W B are implied by the given set of FDs, we can replace WY B, WY V, and WC V in the original set with W B (W V already exists in the original set, so we discard the duplicate). 6

Quiz 9 W V WY BV WC V V B BG M BV Y BYH V M W Y H CY W Minimal cover: 1. Split WY BV into WY B and WY V. 2. Since W V and W B are implied by the given set of FDs, we can replace WY B, WY V, and WC V in the original set with W B (W V already exists in the original set, so we discard the duplicate). 3. V Y and BY V can be derived d from the original i set so we can replace BV Y and BYH V with V Y and BY V. 7

Quiz 9 W V WY BV WC V V B BG M BV Y BYH V M W Y H CY W Minimal cover: 1. Split WY BV into WY B and WY V. 2. Since W V and W B are implied by the given set of FDs, we can replace WY B, WY V, and WC V in the original set with W B (W V already exists in the original set, so we discard the duplicate). 3. V Y and BY V can be derived d from the original i set so we can replace BV Y and BYH V with V Y and BY V. 4. We remove redundant FDs: W B. 8

Quiz 9 W V WY BV WC V V B BG M BV Y BYH V M W Y H CY W Minimal cover: 1. Split WY BV into WY B and WY V. 2. Since W V and W B are implied by the given set of FDs, we can replace WY B, WY V, and WC V in the original set with W B (W V already exists in the original set, so we discard the duplicate). 3. V Y and BY V can be derived d from the original i set so we can replace BV Y and BYH V with V Y and BY V. 4. We remove redundant FDs: W B. 5. The final result is: W V V B BG M V Y BY V M W Y H CY W 9

Quiz 9 W V V B BG M V Y BY V M W Y H CY W Lossless 3NF: (WV; {W V}) (VBY; {BY V; V Y; V B}) (BGM; {BG M}) (MW; {M W}) (YH; {Y H}) (CYW; {CY W}) Since BGM is a superkey of the original schema, we don't need to add anything to this decomposition. 10

Quiz 9 BCNF: The schema (BGM; {BG M}) is not in BCNF because M B is entailed by the original set of FDs. Decompose BGM with respect to M B into (BM; {M B}) and (GM; {}), loosing the FD BG M. The schema (CYW; {CY W}) is not in BCNF because W Y is entailed by the original set of FDs. Decompose CYW using W Y into (WY; ;{W Y}) and (WC; {}), loosing CY W. 11

Extra problem 1 Prove that the following sets of FDs are equivalent: F: A B, C A, AB C G: A C, C B, CB A F G F entails G and G entails F 1. F entails G: A + F = ABC, so F entails A C C + F = ABC, so F entails C B CB + F = ABC, so F entails CB A 2. G entails F: A + G = ABC, so G entails A B C + G = ABC, so G entails C A AB + G = ABC, so G entails AB C 12

Extra problem 2 Consider the schema R over the attributes ABCDEFG with the following functional dependencies: AB C, C B, BC DE, E FG and the following multivalued dependencies: R = BC ABDEFG R = EF FGABCD Decompose this schema into 4NF while trying to preserve as many functional dependencies d as possible: first use the 3NF synthesis algorithm, then the BCNF algorithm, and finally the 4NF algorithm. Is the resulting schema after decomposition dependency-preserving? 13

Extra problem 2 AB C, C B, BC DE, E FG 1. 3NF: split the right-hand sides of the FDs and minimize the lfth left-hand sides: AB C, C B, C D, C E, E F, E G Synthesize the 3NF schemas: R1 = (ABC; {AB C}), R2 = (CBDE;{C BDE}), R3 = (EFG; {E FG}) 2. BCNF: R1 is not in BCNF, because C B is implied by our original set of FDs (and C is not a superkey of R1): we decompose R1 further using C B: R11 = (AC; {}) and R12 = (BC; {C B}). 14

Extra problem 2 R11 = (AC; {}), R12 = (BC; {C B}), R2 = (CBDE;{C BDE}), R3 = (EFG; {E FG}) R = BC ABDEFG, R = EF FGABCD 4NF: R = BC ABDEFG projects onto R2 as R2 = BC BDE and it violates 4NF because B = BC BDE is not a superkey. Therefore, we decompose R2 into (BC;{C B})and(BDE;{}). MVD R = EF FGABCD projects onto R3 as R3 = EF FG and it violates 4NF because F = EF FG is not a superkey. Therefore, we decompose R3 into (EF; {E F}) and (FG; {}). 15

Extra problem 2 AB C, C B, C D, C E, E F, E G R = BC ABDEFG, R = EF FGABCD R11 = (AC; {}), R12 = (BC; {C B}) R21 = (BC;{C B}), R22 = (BDE;{}) R31 = (EF; {E F}), R32 = (FG; {}) The decomposition is not dependency preserving: A B, which h was present in the original i schema, is now not derivable from the FDs attached to the schemas in the decomposition. 16

Extra problem 3 Consider the schema R over the attributes ABCDEFG: 17 DE F, BC AD, FD G, F DE, D E R = ABCFG BCDE Compute 4NF: 1. 3NF: minimal cover: Split the LHS: DE F, BC A, BC D, FD G, F D, F E, D E Reduce the RHS: Since D E, we can delete E in the LHS of DE F: D F Since F D, we can delete D in the LHS of FD G: F G Remove redundant FDs: D F, BC A, BC D, F G, F D, D E

Extra problem 3 D F, BC A, BC D, F G, F D, D E R = ABCFG BCDE 18 3NF: (DEF; {D EF}) (BCAD; {BC AD}) (FGD; {F GD}) This decomposition is lossless since BCAD + = BCADEFG, i.e., the attribute set of the second schema is a superkey of the original schema. BCNF: yes 4NF: We project the MVD on BCAD: BCAD = ABC BCD. ABC BCD = BC is a superkey of the schema (BC AD), so, this MVD does not violate the 4NF.

Extra problem 4 Consider R=BCEGVWY with the MVDs: 19 MVD1: R = WBCY YEVG MVD2: R =WBCE WBYVG MVD3: R =WBY CYEVG 4NF 1: Use MVD1 to obtain the following decomposition: WBCY, YEVG. Use MVD2 to WBCY to yield WBC, WBY. Use MVD3 cannot be used to decompose WBC because the join attribute, Y, is not in this attribute set. MVD3 cannot be used to decompose WBY or YEVG because it projects as a trivial dependency in these cases: WBY=WBY Y and YEVG = Y YEVG. 4NF 2: the decomposition ii 4NF 1 is not unique: we can apply MVD3 and then MVD1 then will obtain: WBY, CY, YEVG.