Relational Database Design Theory Part II. Announcements (October 12) Review. CPS 116 Introduction to Database Systems

Similar documents
Relational Database Design

Chapter 3 Design Theory for Relational Databases

Schema Refinement: Other Dependencies and Higher Normal Forms

UVA UVA UVA UVA. Database Design. Relational Database Design. Functional Dependency. Loss of Information

Information Systems for Engineers. Exercise 8. ETH Zurich, Fall Semester Hand-out Due

Information Systems (Informationssysteme)

CS54100: Database Systems

Databases Lecture 8. Timothy G. Griffin. Computer Laboratory University of Cambridge, UK. Databases, Lent 2009

CSC 261/461 Database Systems Lecture 13. Spring 2018

Lossless Joins, Third Normal Form

Normalization. October 5, Chapter 19. CS445 Pacific University 1 10/05/17

Relational Design Theory

Design theory for relational databases

Schema Refinement and Normal Forms

DESIGN THEORY FOR RELATIONAL DATABASES. csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018

Functional Dependencies & Normalization. Dr. Bassam Hammo

SCHEMA NORMALIZATION. CS 564- Fall 2015

Design Theory for Relational Databases

Functional Dependencies

Database Design and Implementation

Functional Dependencies. Applied Databases. Not all designs are equally good! An example of the bad design

Constraints: Functional Dependencies

Functional Dependency Theory II. Winter Lecture 21

Relational Database Design

FUNCTIONAL DEPENDENCY THEORY II. CS121: Relational Databases Fall 2018 Lecture 20

Databases 2012 Normalization

Functional Dependency and Algorithmic Decomposition

Chapter 10. Normalization Ext (from E&N and my editing)

Relational Design: Characteristics of Well-designed DB

10/12/10. Outline. Schema Refinements = Normal Forms. First Normal Form (1NF) Data Anomalies. Relational Schema Design

Relational Design Theory II. Detecting Anomalies. Normal Forms. Normalization

CS322: Database Systems Normalization

Chapter 3 Design Theory for Relational Databases

DECOMPOSITION & SCHEMA NORMALIZATION

Normal Forms (ii) ICS 321 Fall Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa

INF1383 -Bancos de Dados

Chapter 8: Relational Database Design

CSC 261/461 Database Systems Lecture 11

Schema Refinement and Normal Forms. The Evils of Redundancy. Schema Refinement. Yanlei Diao UMass Amherst April 10, 2007

Design Theory for Relational Databases. Spring 2011 Instructor: Hassan Khosravi

Schema Refinement and Normal Forms. Why schema refinement?

Chapter 11, Relational Database Design Algorithms and Further Dependencies

Constraints: Functional Dependencies

Design Theory. Design Theory I. 1. Normal forms & functional dependencies. Today s Lecture. 1. Normal forms & functional dependencies

CSC 261/461 Database Systems Lecture 12. Spring 2018

Schema Refinement & Normalization Theory

Review: Keys. What is a Functional Dependency? Why use Functional Dependencies? Functional Dependency Properties

A few details using Armstrong s axioms. Supplement to Normalization Lecture Lois Delcambre

CSC 261/461 Database Systems Lecture 10 (part 2) Spring 2018

Schema Refinement and Normal Forms

Introduction to Data Management. Lecture #7 (Relational DB Design Theory II)

Introduction. Normalization. Example. Redundancy. What problems are caused by redundancy? What are functional dependencies?

Schema Refinement. Feb 4, 2010

CS122A: Introduction to Data Management. Lecture #13: Relational DB Design Theory (II) Instructor: Chen Li

Relational-Database Design

Schema Refinement and Normalization

The Evils of Redundancy. Schema Refinement and Normal Forms. Functional Dependencies (FDs) Example: Constraints on Entity Set. Example (Contd.

Chapter 7: Relational Database Design

Normal Forms Lossless Join.

Functional Dependencies and Normalization

The Evils of Redundancy. Schema Refinement and Normal Forms. Example: Constraints on Entity Set. Functional Dependencies (FDs) Example (Contd.

The Evils of Redundancy. Schema Refinement and Normal Forms. Example: Constraints on Entity Set. Functional Dependencies (FDs) Refining an ER Diagram

Lecture #7 (Relational Design Theory, cont d.)

Design Theory for Relational Databases

Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) CIS 330, Spring 2004 Lecture 11 March 2, 2004

Database Design and Normalization

Schema Refinement and Normal Forms Chapter 19

Schema Refinement and Normal Forms. Chapter 19

CS 186, Fall 2002, Lecture 6 R&G Chapter 15

Schema Refinement and Normal Forms. Case Study: The Internet Shop. Redundant Storage! Yanlei Diao UMass Amherst November 1 & 6, 2007

Practice and Applications of Data Management CMPSCI 345. Lecture 16: Schema Design and Normalization

Relational Design Theory I. Functional Dependencies: why? Redundancy and Anomalies I. Functional Dependencies

Normal Forms. Dr Paolo Guagliardo. University of Edinburgh. Fall 2016

The Evils of Redundancy. Schema Refinement and Normalization. Functional Dependencies (FDs) Example: Constraints on Entity Set. Refining an ER Diagram

CSE 344 AUGUST 6 TH LOSS AND VIEWS

Schema Refinement and Normal Forms

Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) [R&G] Chapter 19

Chapter 7: Relational Database Design. Chapter 7: Relational Database Design

Introduction to Data Management. Lecture #6 (Relational DB Design Theory)

Lectures 6. Lecture 6: Design Theory

CAS CS 460/660 Introduction to Database Systems. Functional Dependencies and Normal Forms 1.1

CSE 544 Principles of Database Management Systems

CSE 132B Database Systems Applications

Schema Refinement and Normal Forms

Problem about anomalies

Database Design: Normal Forms as Quality Criteria. Functional Dependencies Normal Forms Design and Normal forms

CSIT5300: Advanced Database Systems

Relational Database Design

CSC 261/461 Database Systems Lecture 8. Spring 2017 MW 3:25 pm 4:40 pm January 18 May 3 Dewey 1101

FUNCTIONAL DEPENDENCY THEORY. CS121: Relational Databases Fall 2017 Lecture 19

Database System Concepts, 5th Ed.! Silberschatz, Korth and Sudarshan See for conditions on re-use "

CMPT 354: Database System I. Lecture 9. Design Theory

Consider a relation R with attributes ABCDEF GH and functional dependencies S:

Comp 5311 Database Management Systems. 5. Functional Dependencies Exercises

Introduction to Data Management. Lecture #6 (Relational Design Theory)

Exam 1 Solutions Spring 2016

Schema Refinement & Normalization Theory: Functional Dependencies INFS-614 INFS614, GMU 1

Database Design and Normalization

Functional Dependencies

Introduction to Data Management CSE 344

Transcription:

Relational Database Design Theory Part II CPS 116 Introduction to Database Systems Announcements (October 12) 2 Midterm graded; sample solution available Please verify your grades on Blackboard Project milestone #1 due today Review 3 Functional dependencies X Y: If two rows agree on X, they must agree on Y A generalization of the key concept n-key functional dependencies: a source of redundancy n-trivial X Y where X is not a superkey Called a BCNF violation BCNF decomposition: a method for removing redundancies Given R(X, Y, Z) and a BCNF violation X Y, decompose R into R 1 (X, Y) and R 2 (X, Z) A lossless join decomposition Schema in BCNF has no redundancy due to FD s

Next 4 3NF (BCNF is too much) Multivalued dependencies: another source of redundancy (BCNF is not enough) Motivation for 3NF 5 Address (street_address, city, state, zip) street_address, city, state zip zip city, state Keys {street_address, city, state} {street_address, zip} BCNF? To decompose or not to decompose 6 Address 1 (zip, city, state) Address 2 (street_address, zip) FD s in Address 1 FD s in Address 2 Hey, where is street_address, city, state zip? Cannot check without joining Address 1 and Address 2 back together Problem: Some lossless join decomposition is not dependency-preserving Dilemma: Should we get rid of redundancy at the expense of making constraints harder to enforce?

3NF 7 R is in Third rmal Form (3NF) if for every non-trivial FD X A (where A is single attribute), either X is a superkey of R, or A is a member of at least one key of R Intuitively, BCNF decomposition on X A would break the key containing A So Address is already in 3NF Tradeoff: Can enforce all original FD s on individual decomposed relations Might have some redundancy due to FD s BNCF = no redundancy? 8 Student (SID, CID, club) Suppose your classes have nothing to do with the clubs you join FD s? BNCF? Redundancies? SID CID club 142 CPS116 ballet 142 CPS116 sumo 142 CPS114 ballet 142 CPS114 sumo 123 CPS116 chess 123 CPS116 golf......... Multivalued dependencies 9 A multivalued dependency (MVD) has the form X Y, where X and Y are sets of attributes in a relation R X Y means that whenever two rows in R agree on all the attributes of X, then we can swap their Y components and get two new rows that are also in R X Y Z a b1 c1 a b2 c2... a b1...... c2 a b2 c1......... Must be in R too

MVD examples 10 Student (SID, CID, club) SID CID Complete MVD + FD rules 11 FD reflexivity, augmentation, and transitivity MVD complementation: If X Y, then X attrs(r) X Y MVD augmentation: If X Y and V W, then XW YV MVD transitivity: If X Y and Y Z, then X Z Y Replication (FD is MVD): If X Y, then X Y Try proving things using these! Coalescence: If X Y and Z Y and there is some W disjoint from Y such that W Z, then X Z An elegant solution: chase Given a set of FD s and MVD s D, does another dependency d (FD or MVD) follow from D? Procedure Start with the hypothesis of d, and treat them as seed tuples in a relation Apply the given dependencies in D repeatedly If we apply an FD, we infer equality of two symbols If we apply an MVD, we infer more tuples If we infer the conclusion of d, we have a proof Otherwise, if nothing more can be inferred, we have a counterexample 12

Proof by chase 13 In R(A, B, C, D), does A B and B C imply that A C? A B B C B C Have a b1 c1 d1 a b2 c2 d2 a b2 c1 d1 a b1 c2 d2 a b2 c1 d2 a b2 c2 d1 a b1 c2 d1 a b1 c1 d2 Need a b1 c2 d1 a b2 c1 d2 Another proof by chase 14 In R(A, B, C, D), does A B and B C imply that A C? A B B C Have a b1 c1 d1 a b2 c2 d2 b1 = b2 Need c1 = c2 c1 = c2 In general, both new tuples and new equalities may be generated Counterexample by chase 15 In R(A, B, C, D), does A BC and CD B imply that A B? A BC Have a b1 c1 d1 a b2 c2 d2 a b2 c2 d1 a b1 c1 d2 Counterexample! Need b1 = b2

16 A relation R is in Fourth rmal Form () if For every non-trivial MVD X Y in R, X is a superkey That is, all FD s and MVD s follow from key other attributes (i.e., no MVD s, and no FD s besides key functional dependencies) is stronger than BCNF Because every FD is also a MVD decomposition algorithm 17 Find a violation A non-trivial MVD X Y in R where X is not a superkey Decompose R into R 1 and R 2, where R 1 has attributes X Y R 2 has attributes X Z (Z contains attributes not in X or Y) Repeat until all relations are in Almost identical to BCNF decomposition algorithm Any decomposition on a violation is lossless decomposition example Student (SID, CID, club) violation: SID CID SID CID club 142 CPS116 ballet 142 CPS116 sumo 142 CPS114 ballet 142 CPS114 sumo 123 CPS116 chess 123 CPS116 golf......... 18 Enroll (SID, CID) SID CID 142 CPS116 142 CPS114 123 CPS116...... Join (SID, club) SID club 142 ballet 142 sumo 123 chess 123 golf......

3NF, BCNF,, and beyond 19 Anomaly/normal form Lose FD s? Redundancy due to FD s Redundancy due to MVD s 3NF BCNF Of historical interests 1NF: All column values must be atomic 2NF: Slightly more relaxed than 3NF Summary 20 Philosophy behind BCNF, : Data should depend on the key, the whole key, and nothing but the key! Philosophy behind 3NF: But not at the expense of more expensive constraint enforcement!