Dr. Alexandra I. Cristea CS 319: Theory of Databases: C3.

Slides:



Advertisements
Similar presentations
(Fuzzy Set Operations)
Advertisements

Applications Computational LogicLecture 11 Michael Genesereth Spring 2004.
1 Knowledge and reasoning – second part Knowledge representation Logic and representation Propositional (Boolean) logic Normal forms Inference in propositional.
Inference in First-Order Logic
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Chapter 1 The Study of Body Function Image PowerPoint
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
UNITED NATIONS Shipment Details Report – January 2006.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Properties of Real Numbers CommutativeAssociativeDistributive Identity + × Inverse + ×
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Year 6 mental test 10 second questions
Fourth normal form: 4NF 1. 2 Normal forms desirable forms for relations in DB design eliminate redundancies avoid update anomalies enforce integrity constraints.
5NF and other normal forms
1 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Normalisation 5.
1 Term 2, 2004, Lecture 2, Normalisation - IntroductionMarian Ursu, Department of Computing, Goldsmiths College Normalisation Introduction.
1 Constraints and Updating Hugh Darwen CS252.HACD: Fundamentals of Relational Databases Section 7: Constraints.
CS 319: Theory of Databases
1 Relational Algebra, Part III, and Other Operators Hugh Darwen CS252.HACD: Fundamentals of Relational.
1 Relational Algebra, Principles and Part I Hugh Darwen CS252.HACD: Fundamentals of Relational Databases.
Dr. Alexandra I. Cristea CS 319: Theory of Databases.
Dr. A.I. Cristea CS 319: Theory of Databases: FDs.
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C6.
1 Abstraction (Cont’d) Defining an Abstract Domain variable elimination, data abstraction, predicate abstraction Abstraction for Universal/Existential.
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
ABC Technology Project
Bellwork Do the following problem on a ½ sheet of paper and turn in.
2 |SharePoint Saturday New York City
VOORBLAD.
Quadratic Inequalities
Chapter 16: Relational Database Design and Further Dependencies
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
Joint work with Andre Lieutier Dassault Systemes Domain Theory and Differential Calculus Abbas Edalat Imperial College Oxford.
1 Declarative Programming Motivation Warm Fuzzies What is Logic?... Logic Programming? Mechanics of Prolog Terms, Substitution, Unification, Horn Clauses,
Schema Refinement: Canonical/minimal Covers
© 2012 National Heart Foundation of Australia. Slide 2.
Abbas Edalat Imperial College London Contains joint work with Andre Lieutier (AL) and joint work with Marko Krznaric (MK) Data Types.
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
Functional Dependencies and Normalization for Relational Databases
25 seconds left…...
Januar MDMDFSSMDMDFSSS
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
12 System of Linear Equations Case Study
Relational Algebra and Relational Calculus
PSSA Preparation.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
1 Chapter 13 Nuclear Magnetic Resonance Spectroscopy.
The Pumping Lemma for CFL’s
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.
Database Management COP4540, SCS, FIU Functional Dependencies (Chapter 14)
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C3.
Logical Database Design (1 of 3) John Ortiz Lecture 6Logical Database Design (1)2 Introduction  The logical design is a process of refining DB schema.
1 Lecture 6: Schema refinement: Functional dependencies
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Deanship of Distance Learning Avicenna Center for E-Learning 1 Session - 7 Sequence - 2 Normalization Functional Dependencies Presented by: Dr. Samir Tartir.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.
CS542 1 Schema Refinement Chapter 19 (part 1) Functional Dependencies.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
Functional Dependencies and Normalization for Relational Databases 1 Chapter 15 تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Normalization Functional Dependencies Presented by: Dr. Samir Tartir
Handout 4 Functional Dependencies
Relational Database Design Theory
Presentation transcript:

Dr. Alexandra I. Cristea CS 319: Theory of Databases: C3

(provisionary) Content 1.Generalities DB 2.Integrity constraints (FD revisited) 3.Relational Algebra (revisited) 4.Query optimisation 5.Tuple calculus 6.Domain calculus 7.Query equivalence 8.LLJ, DP and applications 9.Temporal Data 10.The Askew Wall 2

… previous Proving with Armstrong axioms (non)Redundancy of FDs 3

FD Part 3 Soundness and Completeness of Armstrongs axioms 4

Armstrongs Axioms: Sound & Complete Ingredients: Functional Dependency (reminder) –Definition –Inference rules –Closure of F : F+ F+: Set of all FDs obtained by applying inferences rules on a basic set of FDs –Issues and resolutions Armstrongs Axioms (reminder) –3 inferences rules for obtaining the closure of F –Properties of the Armstrongs Axioms They are a sound an complete set of inference rules Proof of the completeness 5

Functional Dependency -A functional dependency (FD) has the form X Y where X and Y are sets of attributes in a relation R X Y iff any two tuples that agree on X value also agree on Y value X Y if and only if: for any instance r of R for any tuples t 1 and t 2 of r t 1 (X) = t 2 (X) t 1 (Y) = t 2 (Y) 6

Inference of Functional Dependencies Suppose R is a relation scheme, and F is a set of functional dependencies for R If X, Y are subsets of attributes of Attr(R) and if all instances r of R which satisfy the FDs in F also satisfy X Y, then we say that F entails (logically implies) X Y, written F X Y In other words: there is no instance r of R that does not satisfy X Y Example if F = { A B, B C } then F A C if F = { S A, SI P } then F S I AP, F SP SAP etc. ABC SA PI 7

Functional Dependency Issue: –How to represent set of ALL FDs for a relation R? Solution –Find a basic set of FDs ((canonical) cover) –Use axioms for inferring –Represent the set of all FDs as the set of FDs that can be inferred from a basic set of FDs Axioms –they must be a sound and complete set of inference rules 8

Set of Functional Dependencies F* coverFormal Definition of F*, the cover of F: Informal Definitions –F* is the set of all FDs logically implied by F (entailed)... usually F* is much too large even to enumerate! if F is a set of FDs, then F * { X Y F X Y } 9

F* Usually F * is much too large even to enumerate! Example (3 attributes, 2 FDs and 43 entailed dependencies) Attr(R)=ABC and F ={ A B, B C } then F * is A S for all [subset of ABC] 8 FDs B BC, B B, B C, B 4 FDs C C, C, 3 FDs AB S for all subsets S of ABC 8 FDs AC S for all subsets S of ABC 8 FDs BC BC, BC B, BC C, BC 4 FDs ABC S for all subsets S of ABC 8 FDs ABC 10

Armstrongs Axioms Axioms for reasoning about FDs F1: reflexivityif Y X then X Y F2: augmentation if X Y then XZ YZ F3: transitivityif X Y and Y Z then X Z 11

F+F+ Informal Definition Formal Definition closure F + (the closure of F) is the set of dependencies which can be deduced from F by applying Armstrongs axioms if F is a set of FDs, then F + { X Y F |= X Y } 12

Armstrongs Axioms Theorem: Armstrongs axioms are a sound and complete set of inference rules –Sound: all Armstrong axioms are valid (correct / hold) –Complete: all fds that are entailed can be deduced with the help of the Armstrong axioms How to: –Prove the soundness? 13

Armstrongs Axioms Theorem: Armstrongs axioms are a sound and complete set of inference rules –Sound: the Armstrongs rules generate only FDs in F* F + F* –Complete: the Armstrongs rules generate all FDs in F* F* F + –If complete and sound then F + = F* Here –Proof of the completeness 14

Armstrongs Theorems Additional rules derived from axioms –Union if A B and A C, then A BC –Decomposition if A BC, then A B and A C AB C A B C For the proof, we can use: 15

Completeness of the Armstrongs Axioms Proving that Armstrongs axioms are a complete set of inference rules Armstrongs axioms generate all FDs in F* F* F + 16

Completeness of the Armstrongs Axioms First define X +, the closure of X with respect to F: X + is the set of attributes A such that X A can be deduced from F with Armstrongs axioms Note that we can deduce that X Y for some set Y by applying Armstrongs axioms if and only if Y X + Attr(R)=LMNO X=L F={L M, M N, O N} then X + = L + = LMN LMN O Example: 17

X Y F + Y X + Proof: We can deduce that X Y for some set Y by applying Armstrongs axioms if and only if Y X + Y X + X Y F + Y X + and suppose that A Y then X A F + (definition of X + ) A Y: X A F + X Y F + (union rule) X Y F + Y X + X Y F + and suppose that A Y then X A F + (decomposition rule) A X + (definition of X + ) A Y: A X + Y X + 18

Completeness ( F* F + ) of the Armstrongs Axioms Completeness: ( R, X,Y Attr R), F true in R : : X Y F * => X Y F + ) Idea: (A => B) ( A v B) (B v A) ( B => A) To establish completeness, it is sufficient to show: if X Y cannot be deduced from F using Armstrongs axioms then also X Y is not logically implied by F: ( R, X,Y Attr( R), F true in R : : X Y F + => X Y F * ) (In other words) there is a relational instance r in R (r R) in which all the dependencies in F are true, but X Y does not hold X Y F* enough: Counter example!! 19

Completeness of the Armstrongs Axioms Example for the proof idea for a given R, F, X: If X Y cannot be deduced using Armstrongs axioms: then there is a relational instance for R in which all the dependencies in F are true, but X Y does not hold Counter example: R=LMNO X=L F={L M, M N, O N} then X + = LMN LMN O L O cannot be deduced (so not in F+) but also does not hold (not in F*) 20

What we want to prove thus: ( R, X,Y Attr( R), F true in R : : X Y F + => X Y F * ) (In other words) Counterexample – by construction: –for any R, any X, Y, any F true in R, –with X->Y not inferable from the axioms –there is a relational instance r in R (r R) –in which all the dependencies in F are true ( F true in R ), –but X Y does not hold 21

Completeness of the Armstrongs Axioms Suppose one can not deduce X Y from Armstrongs axioms for an arbitrary R, F, X,Y; construct counter-ex. Consider the instance r 0 for R with 2 tuples (assuming Boolean attributes, or more generally, that the two tuples agree on X+ but disagree elsewhere) Attributes of X + Other Attributes 1 1 … … … 0 Relational instance r 0 for R with 2 tuples L + = LMN LMNO R=LMNO X=L then X + = L + L O cannot be deduced Example: 22

Completeness of the Armstrongs Axioms Check that all the dependencies in F are true in R: –Suppose that V W is a dependency in F If V is not a subset of X +, the dependency holds in r 0 If V is a subset of X +, then both X V, and then X W can be deduced by Armstrongs axioms. This means that W is a subset of X +, and thus V W holds in r 0 Attributes of X + Other Attributes 1 1 … … … 0 Relational instance r 0 for R with 2 tuples 23

Completeness of the Armstrongs Axioms Check that all the dependencies in F are true –Extended Example (more tuples) O N is a dependency in F but O is not a subset of X +, the dependency holds in r 0 M N is a dependency in F and M is a subset of X +, then both L M, and L N can be deduced by Armstrongs axioms. This means that N is a subset of X +, and thus M N holds in r 0 R=LMNO X=L F={L M, M N, O N} then X + = LMN 24

Completeness of the Armstrongs Axioms Proof that X Y does not hold in r 0 : –Recall that we can deduce that X Y for some set Y by applying Armstrongs axioms if and only if Y X + –By assumption, we cant deduce that X Y holds in r 0 –Hence Y contains (at least) an attribute not in the subset X +, confirming that X Y does not hold in r 0 Attributes of X + Other Attributes 1 1 … … … 0 Relational instance r 0 for R with 2 tuples ( R, X,Y Attr(R), F true in R : : X -> Y F+ => X -> Y F*) 25

Completeness of the Armstrongs Axioms We have proved the correctness (last module) and here, the completeness of Armstrongs Axioms: –How can we prove the completeness of another set of rules? Repeat the proof for this set Deduce the Armstrongs Axioms from this set –How can we disprove the completeness of another set of rules? By showing (via a counterexample) that some consequence of Armstrong's rules cannot be deduced from them (see the proof technique for non-redundancy) 26

Completeness of the Armstrongs Axioms Exercise –Are the following set of rules a sound and complete set of inference rules? (X, Y, Z, W R) S1: X X S2: if X Y then XZ Y S3: if X Y, Y Z then XW ZW (This is a typical exam question ) 27

Solution (soundness) so by F1 then by F2 so by F1 so by F3 ifthen by F3 so by F2 S1 S2 S3 28

Solution (completeness) so {S1} Y Y, {S2}YZ Y ifthen hence X Y {S1} X X, X Y, so {S3} XZ YZ ifthen hence A1 A2 A3 if then {S3} hence 29

Completeness of the Armstrongs Axioms Exercises –Are the following set of rules a complete set of inference rules? Ø A B AB Suppose Apply above rules exhaustivelyHence: answer is NO obtained from F1-3 but not from R1-3 R1: X X R2: X Y then XZ Y R3: X Y, Y Z then X Z 30

Summary We have learned how to prove that the Armstrong axiom set is complete (and we already knew it is sound) We can now prove the soundness and completeness of any other set of axioms 31

Extra Question: –Can we have a sound and complete set of inference rules consisting of only 2 rules? –What about 1 rule? 32

… to follow Dependency preserving, Lossless join, Normal forms algorithms 33