Design theory for relational databases

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

Chapter 3 Design Theory for Relational Databases

CSC 261/461 Database Systems Lecture 13. Spring 2018

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

Design Theory for Relational Databases

Chapter 3 Design Theory for Relational Databases

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

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

Relational Design Theory

CSC 261/461 Database Systems Lecture 12. Spring 2018

Design Theory for Relational Databases

12/3/2010 REVIEW ALGEBRA. Exam Su 3:30PM - 6:30PM 2010/12/12 Room C9000

Relational-Database Design

11/1/12. Relational Schema Design. Relational Schema Design. Relational Schema Design. Relational Schema Design (or Logical Design)

CSE 344 MAY 16 TH NORMALIZATION

Relational Database Design

Comp 5311 Database Management Systems. 5. Functional Dependencies Exercises

Lossless Joins, Third Normal Form

CSE 344 AUGUST 3 RD NORMALIZATION

Relational Database Design

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

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

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

CSC 261/461 Database Systems Lecture 11

Schema Refinement and Normal Forms

Functional Dependencies and Normalization

CSE 344 AUGUST 6 TH LOSS AND VIEWS

Schema Refinement & Normalization Theory

Introduction to Management CSE 344

CSE 303: Database. Outline. Lecture 10. First Normal Form (1NF) First Normal Form (1NF) 10/1/2016. Chapter 3: Design Theory of Relational Database

Functional Dependency and Algorithmic Decomposition

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

Relational Database Design

CS54100: Database Systems

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

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

11/6/11. Relational Schema Design. Relational Schema Design. Relational Schema Design. Relational Schema Design (or Logical Design)

Lectures 6. Lecture 6: Design Theory

Chapter 11, Relational Database Design Algorithms and Further Dependencies

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

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

Normal Forms Lossless Join.

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

Introduction to Data Management CSE 344

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

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

CSE 544 Principles of Database Management Systems

Functional Dependencies and Normalization

Schema Refinement and Normal Forms

Database Design and Implementation

Schema Refinement and Normalization

Background: Functional Dependencies. æ We are always talking about a relation R, with a æxed schema èset of attributesè and a

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

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

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

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

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

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

INF1383 -Bancos de Dados

Functional Dependencies

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

Schema Refinement and Normal Forms. Chapter 19

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

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

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

Schema Refinement and Normal Forms

L14: Normalization. CS3200 Database design (sp18 s2) 3/1/2018

Functional Dependencies

Desirable properties of decompositions 1. Decomposition of relational schemes. Desirable properties of decompositions 3

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

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

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

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

Schema Refinement and Normal Forms Chapter 19

Schema Refinement. Feb 4, 2010

SCHEMA NORMALIZATION. CS 564- Fall 2015

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

Introduction to Data Management CSE 344

Functional Dependencies & Normalization. Dr. Bassam Hammo

Normaliza)on and Func)onal Dependencies

Databases 2012 Normalization

CSIT5300: Advanced Database Systems

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

Schema Refinement and Normal Forms. Why schema refinement?

Design Theory: Functional Dependencies and Normal Forms, Part I Instructor: Shel Finkelstein

HKBU: Tutorial 4

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

Homework 2 (by Prashasthi Prabhakar) Solutions Due: Wednesday Sep 20, 11:59pm

Functional Dependencies and Normalization. Instructor: Mohamed Eltabakh

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

Functional Dependencies

Homework 2 (by Prashasthi Prabhakar) Due: Wednesday Sep 20, 11:59pm

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

Functional Dependency Theory II. Winter Lecture 21

Detecting Functional Dependencies Felix Naumann

A CORRECTED 5NF DEFINITION FOR RELATIONAL DATABASE DESIGN. Millist W. Vincent ABSTRACT

Information Systems (Informationssysteme)

Schema Refinement and Normal Forms

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

Transcription:

Design theory for relational databases 1. Consider a relation with schema R(A,B,C,D) and FD s AB C, C D and D A. a. What are all the nontrivial FD s that follow from the given FD s? You should restrict yourself to FD s with attributes on the right side. b. What are all the keys of R? c. What are all the superkeys for R that are not keys? a. We could try inference rules to deduce new dependencies until we are satisfied we have them all. A more systematic way is to consider the closures of all 15 nonempty sets of attributes. For the single attributes we have {A} + = A, {B} + = B, {C} + = ACD, and {D} + = AD. Thus, the only new dependency we get with a single attribute on the left is C A. Now consider pairs of attributes: {AB} + = ABCD, so we get new dependency AB D. {AC} + = ACD, and AC D is nontrivial. {AD} + = AD, so nothing new. {BC} + = ABCD, so we get BC A, and BC D. {BD} + = ABCD, giving us BD A and BD C. {CD} + = ACD, giving CD A. For the triples of attributes, {ACD} + = ACD, but the closures of the other sets are each ABCD. Thus, we get new dependencies ABC D, ABD C, and BCD A. Since {ABCD} + = ABCD, we get no new dependencies. The collection of 11 new dependencies mentioned above are: C A, AB D, AC D, BC A, BC D, BD A, BD C, CD A, ABC D, ABD C, and BCD A. b. From the analysis of closures above, we find that AB, BC, and BD are keys. All other sets either do not have ABCD as the closure or contain one of these three sets.

c. The superkeys are all those that contain one of those three keys. That is, a superkey that is not a key must contain B and more than one of A, C, and D. Thus, the (proper) superkeys are ABC, ABD, BCD, and ABCD. 2. Suppose we have a relation R(A,B,C,D,E) with some set of FD s and we wish to project those FD s onto relations S(A,B,C). Give the FD s that hold in S if the FD s for R are: a. AB DE, C E, D C and E A b. A D, BD E,AC E and DE B a. We need to compute the closures of all subsets of {ABC}, although there is no need to think about the empty set or the set of all three attributes. Here are the calculations for the remaining six sets: {A} + =A {B} + =B {C} + =ACE {AB} + =ABCDE {AC} + =ACE {BC} + =ABCDE We ignore D and E, so a basis for the resulting functional dependencies for ABC is: C A, AB C and BC->A is true. b. We need to compute the closures of all subsets of {ABC}, although there is no need to think about the empty set or the set of all three attributes. Here are the calculations for the remaining six sets: {A} + =AD {B} + =B {C} + =C {AB} + =ABDE {AC} + =ABCDE {BC} + =BC We ignore D and E, so a basis for the resulting functional dependencies for ABC is: AC B.

3. For the following relation schemas and set of FD s R(A,B,C,D) with FD s AB C, C D and D A. Indicate all the BCNF violations. Do not forget to consider FD s that are not in the given set, but follow from them. Decompose the relations, as necessary, into collections of relations that are in BCNF. In the solution to Exercise 1 we found that there are 14 nontrivial dependencies, including the three given ones and eleven derived dependencies. They are: C A, C D, D A, AB D, AB C, AC D, BC A, BC D, BD A, BD C, CD A, ABC D, ABD C, and BCD A. We also learned that the three keys were AB, BC, and BD. Thus, any dependency above that does not have one of these pairs on the left is a BCNF violation. These are: C A, C D, D A, AC D, and CD A. One choice is to decompose using the violation C D. Using the above FDs, we get ACD and BC as decomposed relations. BC is surely in BCNF, since any twoattribute relation is. Using Algorithm 3.12 to discover the projection of FDs on relation ACD, we discover that ACD is not in BCNF since C is its only key. However, D A is a dependency that holds in ABCD and therefore holds in ACD. We must further decompose ACD into AD and CD. Thus, the three relations of the decomposition are BC, AD, and CD. 4. Let R(A,B,C,D,E) be decomposed into relations with the following three set of attributes {A,B,C}, {B,C,D}, and {A,C,E}. For each of the following sets of FD s, use the chase test to tell whether the decomposition of R is lossless. For those that are not lossless, give an example of an instance of R that returns more than R when projected onto the decomposed relation and rejoined. a. B E and CE A. This is the initial tableau:

a 2 b c d e 2 a b 3 c d 3 e This is the final tableau after applying FDs B E and CE A. a b c d e 1 a b 3 c d 3 e Since there is not an unsubscripted row, the decomposition for R is not lossless for this set of FDs. We can use the final tableau as an instance of R as an example for why the join is not lossless. The projected relations are: A B C a b c a b 3 c B C D b c d 1 b c d b 3 c d 3 A C E a c e 1 a c e The joined relation is: a b c d 1 e a b c d e 1 a b c d e a b 3 c d e1

a b 3 c d 3 e The joined relation has three more tuples than the original tableau.