The Closure of a set of Attributes

Slides:



Advertisements
Similar presentations
Dr. Alexandra I. Cristea CS 319: Theory of Databases.
Advertisements

Dr. Alexandra I. Cristea CS 319: Theory of Databases: C3.
primary key constraint foreign key constraint
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.
1 Design Theory. 2 Minimal Sets of Dependancies A set of dependencies is minimal if: 1.Every right side is a single attribute 2.For no X  A in F and.
Database Management COP4540, SCS, FIU Functional Dependencies (Chapter 14)
1 Design Theory. 2 Let U be a set of attributes and F be a set of functional dependencies on U. Suppose that X  U is a set of attributes. Definition:
Multivalued Dependency Prepared by Tomasz Kaciak CS157A.
DATABASE DESIGN Functional Dependencies. Overview n Functional Dependencies n Normalization –Functional dependencies –Normal forms.
Design Theory.
Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Schema Refinement and Normalization Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 6, 2004 Some slide content.
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C3.
Cs3431 Normalization Part II. cs3431 Attribute Closure : Example Consider R (A, B, C, D, E) with FDs A  B, B  C, CD  E Does A  E hold ? (Is A  E.
1 Triggers: Correction. 2 Mutating Tables (Explanation) The problems with mutating tables are mainly with FOR EACH ROW triggers STATEMENT triggers can.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Database Systems Normal Forms. Decomposition Suppose we have a relation R[U] with a schema U={A 1,…,A n } – A decomposition of U is a set of schemas.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
THIRD NORMAL FORM (3NF) A relation R is in BCNF if whenever a FD XA holds in R, one of the following statements is true: XA is a trivial FD, or X is.
Christoph F. Eick: Functional Dependencies, BCNF, and Normalization 1 Functional Dependencies, BCNF and Normalization.
CHAPTER 19 SCHEMA, REFINEMENT AND NORMAL FORMS
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 15.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Chapter 5.1 and 5.2 Brian Cobarrubia Database Management Systems II January 31, 2008.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.
CS 222 Database Management System Spring Lecture 4 Database Design Theory Korra Sathya Babu Department of Computer Science NIT Rourkela.
© D. Wong Functional Dependencies (FD)  Given: relation schema R(A1, …, An), and X and Y be subsets of (A1, … An). FD : X  Y means X functionally.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
Normal Forms Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems June 18, 2016 Some slide content courtesy of Susan Davidson.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Normalization.
Advanced Normalization
Chapter 15 Relational Design Algorithms and Further Dependencies
Functional Dependency
Normalization Functional Dependencies Presented by: Dr. Samir Tartir
Relational Database Design
CS411 Database Systems 08: Midterm Review Kazuhiro Minami 1.
Module 5: Overview of Database Design -- Normalization
Problem Axiom of addition:
Functional Dependencies, BCNF and Normalization
3.1 Functional Dependencies
Handout 4 Functional Dependencies
Advanced Normalization
Functional Dependencies, BCNF and Normalization
Schema Refinement & Normalization Theory
Schema Refinement and Normalization
Schema Refinement and Normalization
Chapter 7: Relational Database Design
Exercise R(A,B,C,D) with FD’s ABC, CD, and DA
Functional Dependencies and Normalization
Relational Data Base Design in Practice
Normalization cs3431.
Some slides are from Dr. Sara Cohen
CS 405G: Introduction to Database Systems
Instructor: Mohamed Eltabakh
Relational Database Design
Computing Closure of F We could test for whether a relation scheme is in BCNF, if we could compute the closure of F. Closure of F can be computed using.
Schema Refinement and Normalization
Relational Database Theory
CSC 453 Database Systems Lecture
Chapter 3: Design theory for relational Databases
Lecture 09: Functional Dependencies
CS4222 Principles of Database System
Presentation transcript:

The Closure of a set of Attributes The closure of the attributes X, with respect to the FDs F is denoted X+F = {A | F|- X  A} Note: |- means provable using Armstrong’s Axioms If F is clear from the context, we simply write X+ Lemma: Let Y be a set of attributes. Then, Y X+ if and only if F |- X  Y If: Suppose that F|- X->Y. Let Y = A1…Ak. By the axiom of decomposition, it follows that F|-X->Ai, for all i<=k. Therefore, Ai is in X+, for all i<=k. Thus, Y=A…Ak is a subset of X+, as required. Only if: Suppose that Y is a subset of X+. Let Y=A1…Ak. By the definition of X+, it follows that F|-X->Ai, for all i<=k. By the axiom of union, we derive that F|-X->A1..Ak, i.e., F|-X->Y, as required.

Completeness of the Axioms Completeness of the axioms means that everything that נובע is also יכיח, i.e., Equivalently, completeness means that everything that is not יכיח is also not נובע We prove that Armstrong's axioms are complete by using the second definition of completeness

Proof (1) We must show that We prove the contra-positive, i.e., if we cannot prove X  Y from F using Armstrong’s axioms, then X  Y does not follow from F.

Proof (2) Suppose that we cannot prove X  Y from F using Armstrong’s axioms. Let X+ be the closure of X Let R be a relation with all attributes in X and Y, and F and the two tuples: t containing the value “b” for all attributes s containing the value “b” for all attributes in X+, and “a”, for all attributes in R, that are not in X+

Proof (3) We will show the following: R satisfies all functional dependencies in F R does not satisfy X  Y If we can prove both of these, then X  Y does not follow from F, as required.

Proof (4) We start with showing that R satisfies all functional dependencies in F Let W  V be a functional dependency in F. We consider two cases: Case 1: W is not a subset of X+. Then, the two rows in R differ on W, and W  V is satisfied in R. Case 2: W is a subset of X+. By the closure lemma, F|-X  W. Since, W  V is in F, by the axiom of transitivity, it follows that F|-X V. Again, by the closure lemma, we have that V is a subset of X+. The two rows are equal on V, and W  V is satisfied in R.

Proof (5) We now show that R does not satisfy X  Y By the axiom of reflexivity, we have that F|-X  X. By the closure lemma, X is contained in X+. Observe that Y is not contained in X+, since otherwise, by the closure lemma we would have that F|-X Y, which contradicts our assumption. Hence, there is some attribute A in Y that is not in X+. Therefore, s,t are equal on X, but differ on Y Therefore, R does not satisfy X  Y.

Problem Prove or give a counter-example: Let R be a relation containing exactly two attributes. Let F be a set of functional dependencies. Then, R is in BCNF.

Problem We are given R and F It is known that every dependency in F has one attribute on the left side. Prove or show a simple counter example: R is in BCNF if and only if R is in 3NF

Problem Find small(est) examples of R and F such that: R is in BCNF R is in 3NF, but not in BCNF R is not in 3NF

Problem R=(ABCD) F={A->B,C->D,A->D} What is the normal form of R? We have a decomposition R1=(ABC), R2=(BCD) Is this a lossless join decomposition? Is it possible to insert data into R1 and R2 while satisfying A->B and C->D, so that the natural join of R1 and R2 contradicts A->D?

Problem R=(ABC) F={A->B,BC->A} What is the normal form of R? We have a decomposition R1=(AB), R2=(AC) Is this a lossless join decomposition?

Problem 10 Let R=ABCDEG Let F={C->D, E->C, EG->A, G->B} What are all the keys of R? What is the normal form of R? Is the following decomposition lossless? R1=AEG, R2=CE, R3=BG, R4=DEG Keys: EG Normal form: not 3NF The decomposition is lossless It does not preserve C->D AEG: EG->A, CE: E->C, BG: G->B, DEG: E->D

Additional Exercises (Left over from last week)

Problem 1 Let R(A,B,C,D,E) be a table Write an SQL query that returns an empty relation if and only if ABCD holds in R.

Problem 2 Consider the following axiom system: (B1) XX (B2) XYZ then XY, XZ (B3) XYZ, ZC then XYZC Prove that this system is complete by showing how each of Armstrong’s Axioms can be proven from the axioms above

Problem 3 Axiom of difference: If XW ® YW and W ® Y then X ® W Prove this axiom using Armstrongs Axioms or show that it is not sound

Problem 4 Axiom of addition: If X ® Y and W ® V then XW ® YV Prove this axiom using Armstrongs Axioms or show that it is not sound

Problem 5 Prove or give a counter example (X+)+ = X+

Problem Let R=ABCDEG Let F={C->D, E->C, EG->A, G->B} What are all the keys of R? What is the normal form of R? Is the following decomposition lossless? R1=AEG, R2=CE, R3=BG, R4=DEG Keys: EG Normal form: not 3NF The decomposition is lossless It does not preserve C->D AEG: EG->A, CE: E->C, BG: G->B, DEG: E->D