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

Similar documents
Schema Refinement: Other Dependencies and Higher Normal Forms

Relational Database Design

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

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

DECOMPOSITION & SCHEMA NORMALIZATION

Chapter 3 Design Theory for Relational Databases

Lossless Joins, Third Normal Form

CS322: Database Systems Normalization

Databases 2012 Normalization

Relational Database Design

Constraints: Functional Dependencies

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

Design Theory for Relational Databases

SCHEMA NORMALIZATION. CS 564- Fall 2015

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

Functional Dependency Theory II. Winter Lecture 21

Chapter 7: Relational Database Design

Chapter 3 Design Theory for Relational Databases

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

CSC 261/461 Database Systems Lecture 13. Spring 2018

Chapter 8: Relational Database Design

Plan of the lecture. G53RDB: Theory of Relational Databases Lecture 9. Informal exercise from last lecture. Example (from Stanczyk et al.

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

Constraints: Functional Dependencies

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

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

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

Comp 5311 Database Management Systems. 5. Functional Dependencies Exercises

Database Design and Implementation

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

Relational-Database Design

Relational Design Theory

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

Database Design and Normalization

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

Database Tutorial 2: Functional Dependencies and Normal Forms

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

Functional Dependency and Algorithmic Decomposition

CSE 344 AUGUST 6 TH LOSS AND VIEWS

Functional Dependencies & Normalization. Dr. Bassam Hammo

Schema Refinement & Normalization Theory

CS54100: Database Systems

Design theory for relational databases

INF1383 -Bancos de Dados

CSE 132B Database Systems Applications

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

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

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

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

Relational Design: Characteristics of Well-designed DB

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

CSC 261/461 Database Systems Lecture 11

Schema Refinement and Normal Forms. Chapter 19

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

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

Schema Refinement and Normal Forms

Information Systems (Informationssysteme)

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #15: BCNF, 3NF and Normaliza:on

Chapter 11, Relational Database Design Algorithms and Further Dependencies

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

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

Design Theory for Relational Databases

Schema Refinement. Feb 4, 2010

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

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

Functional Dependencies

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

COSC 430 Advanced Database Topics. Lecture 2: Relational Theory Haibo Zhang Computer Science, University of Otago

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

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

CSC 261/461 Database Systems Lecture 12. Spring 2018

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

Functional Dependencies. Getting a good DB design Lisa Ball November 2012

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

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

Lecture 6 Relational Database Design

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen

Shuigeng Zhou. April 6/13, 2016 School of Computer Science Fudan University

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

Lectures 6. Lecture 6: Design Theory

CSE 544 Principles of Database Management Systems

Schema Refinement and Normalization

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

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

Functional Dependencies and Normalization

Plan of the lecture. G53RDB: Theory of Relational Databases Lecture 13. Join dependencies. Multivalued dependencies. Decomposition (non-loss!

Schema Refinement and Normal Forms

Informationslogistik Unit 7: Conceptual Design of Databases Normalization

Schema Refinement and Normal Forms Chapter 19

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

Schema Refinement and Normal Forms

Functional Dependencies and Normalization. Instructor: Mohamed Eltabakh

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

Schema Refinement. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke

Schema Refinement and Normal Forms. Why schema refinement?

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

Introduction to Database Systems CSE 414. Lecture 20: Design Theory

Introduction to Data Management CSE 344

Plan of the lecture. G53RDB: Theory of Relational Databases Lecture 10. Logical consequence (implication) Implication problem for fds

Transcription:

Databases Lecture 8 Timothy G. Griffin Computer Laboratory University of Cambridge, UK Databases, Lent 2009 T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 1 / 15

Lecture 08: Multivalued Dependencies Outline Multivalued Dependencies Fourth Normal Form (4NF) General integrity Constraints T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 2 / 15

Another look at Heath s Rule Given R(Z, W, Y) with FDs F If Z W F +, the R = π Z,W (R) π Z,Y (R) What about an implication in the other direction? That is, suppose we have R = π Z,W (R) π Z,Y (R). Q Can we conclude anything about FDs on R? In particular, is it true that Z W holds? A No! T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 3 / 15

We just need one counter example... R = π A,B (R) π A,C (R) A B C a b 1 c 1 a b 2 c 2 a b 1 c 2 a b 2 c 1 Clearly A B is not an FD of R. A B a b 1 a b 2 A C a c 1 a c 2 T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 4 / 15

A concrete example course_name lecturer text Databases Tim Ullman and Widom Databases Fatima Date Databases Tim Date Databases Fatima Ullman and Widom Assuming that texts and lecturers are assigned to courses independently, then a better representation would in two tables: course_name Databases Databases lecturer Tim Fatima course_name Databases Databases text Ullman and Widom Date T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 5 / 15

Time for a definition! Multivalued Dependencies (MVDs) Let R(Z, W, Y) be a relational schema. A multivalued dependency, denoted Z W, holds if whenever t and u are two records that agree on the attributes of Z, then there must be some tuple v such that 1 v agrees with both t and u on the attributes of Z, 2 v agrees with t on the attributes of W, 3 v agrees with u on the attributes of Y. T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 6 / 15

A few observations Note 1 Every functional dependency is multivalued dependency, (Z W) = (Z W). To see this, just let v = u in the above definition. Note 2 Let R(Z, W, Y) be a relational schema, then (Z W) (Z Y), by symmetry of the definition. T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 7 / 15

MVDs and lossless-join decompositions Fun Fun Fact Let R(Z, W, Y) be a relational schema. The decomposition R 1 (Z, W), R 2 (Z, Y) is a lossless-join decomposition of R if and only if the MVD Z W holds. T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 8 / 15

Proof of Fun Fun Fact Proof of (Z W) = R = π Z,W (R) π Z,Y (R) Suppose Z W. We know (from proof of Heath s rule) that R π Z,W (R) π Z,Y (R). So we only need to show π Z,W (R) π Z,Y (R) R. Suppose r π Z,W (R) π Z,Y (R). So there must be a t R and u R with {r} = π Z,W ({t}) π Z,Y ({u}). In other words, there must be a t R and u R with t.z = u.z. So the MVD tells us that then there must be some tuple v R such that 1 v agrees with both t and u on the attributes of Z, 2 v agrees with t on the attributes of W, 3 v agrees with u on the attributes of Y. This v must be the same as r, so r R. T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 9 / 15

Proof of Fun Fun Fact (cont.) Proof of R = π Z,W (R) π Z,Y (R) = (Z W) Suppose R = π Z,W (R) π Z,Y (R). Let t and u be any records in R with t.z = u.z. Let v be defined by {v} = π Z,W ({t}) π Z,Y ({u}) (and we know v R by the assumption). Note that by construction we have 1 v.z = t.z = u.z, 2 v.w = t.w, 3 v.y = u.y. Therefore, Z W holds. T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 10 / 15

Fourth Normal Form Trivial MVD The MVD Z W is trivial for relational schema R(Z, W, Y) if 1 Z W {}, or 2 Y = {}. 4NF A relational schema R(Z, W, Y) is in 4NF if for every MVD Z W either Z W is a trivial MVD, or Z is a superkey for R. Note : 4NF BCNF 3NF 2NF T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 11 / 15

General Decomposition Method Revisited GDM++ 1 Understand your FDs and MVDs F (compute F + ), 2 find R(X) = R(Z, W, Y) (sets Z, W and Y are disjoint) with either FD Z W F + or MVD Z W F + violating a condition of desired NF, 3 split R into two tables R 1 (Z, W) and R 2 (Z, Y) 4 wash, rinse, repeat T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 12 / 15

Summary We always want the lossless-join property. What are our options? 3NF BCNF 4NF Preserves FDs Yes Maybe Maybe Preserves MVDs Maybe Maybe Maybe Eliminates FD-redundancy Maybe Yes Yes Eliminates MVD-redundancy No No Yes T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 13 / 15

General integrity constraints Suppose that C is some constraint we would like to enforce on our database. Let Q C be a query that captures all violations of C. Enforce (somehow) that the assertion that is always Q C empty. Example C = Z W, and FD that was not preserved for relation R(X), Let Q R be a join that reconstructs R, Let Q R be this query with X X and Q C = σ W W (σ Z=Z (Q R Q R )) T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 14 / 15

Assertions in SQL create view C_violations as... create assertion check_c check not (exists C_violations) T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 15 / 15