Dr. A.I. Cristea CS 319: Theory of Databases: FDs.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

You have been given a mission and a code. Use the code to complete the mission and you will save the world from obliteration…
(Fuzzy Set Operations)
1 Knowledge and reasoning – second part Knowledge representation Logic and representation Propositional (Boolean) logic Normal forms Inference in propositional.
Advanced Piloting Cruise Plot.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
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
Title Subtitle.
My Alphabet Book abcdefghijklm nopqrstuvwxyz.
0 - 0.
ALGEBRAIC EXPRESSIONS
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
MULTIPLYING MONOMIALS TIMES POLYNOMIALS (DISTRIBUTIVE PROPERTY)
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
FACTORING Think Distributive property backwards Work down, Show all steps ax + ay = a(x + y)
Addition Facts
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
Relational data integrity
1 Term 2, 2004, Lecture 2, Normalisation - IntroductionMarian Ursu, Department of Computing, Goldsmiths College Normalisation Introduction.
Around the World AdditionSubtraction MultiplicationDivision AdditionSubtraction MultiplicationDivision.
Probability Distributions
Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: XPath, NameSpaces.
CS 319: Theory of Databases
Dr. Alexandra I. Cristea CS 319: Theory of Databases.
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C3.
Dr. Alexandra I. Cristea CS 252: Fundamentals of Relational Databases: SQL5.
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C6.
ZMQS ZMQS
ABC Technology Project
3 Logic The Study of What’s True or False or Somewhere in Between.
Copyright © 2013, 2009, 2005 Pearson Education, Inc.
VOORBLAD.
Quadratic Inequalities
Solving Equations How to Solve Them
1 Evaluations in information retrieval. 2 Evaluations in information retrieval: summary The following gives an overview of approaches that are applied.
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Squares and Square Root WALK. Solve each problem REVIEW:
Do you have the Maths Factor?. Maths Can you beat this term’s Maths Challenge?
Lets play bingo!!. Calculate: MEAN Calculate: MEDIAN
CS1022 Computer Programming & Principles
Chapter 5 Test Review Sections 5-1 through 5-4.
SIMOCODE-DP Software.
GG Consulting, LLC I-SUITE. Source: TEA SHARS Frequently asked questions 2.
What You Should Learn • Represent and classify real numbers.
Functional Dependencies and Normalization for Relational Databases
Addition 1’s to 20.
25 seconds left…...
Slippery Slope
Copyright © Cengage Learning. All rights reserved.
Test B, 100 Subtraction Facts
Week 1.
We will resume in: 25 Minutes.
A SMALL TRUTH TO MAKE LIFE 100%
1 PART 1 ILLUSTRATION OF DOCUMENTS  Brief introduction to the documents contained in the envelope  Detailed clarification of the documents content.
Chapter 6 Languages: finite state machines
Equivalence Relations
primary key constraint foreign key constraint
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C6.
CS 440 Database Management Systems Lecture 4: Constraints, Schema Design.
DATABASE DESIGN Functional Dependencies. Overview n Functional Dependencies n Normalization –Functional dependencies –Normal forms.
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C3.
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C6.
1 CS 430 Database Theory Winter 2005 Lecture 8: Functional Dependencies Second, Third, and Boyce-Codd Normal Forms.
Functional Dependencies and Normalization for Relational Databases 1 Chapter 15 تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في.
Presentation transcript:

Dr. A.I. Cristea CS 319: Theory of Databases: FDs

2 … previous Generalities on Databases

3 … previous Generalities on Databases Definitions of databases The issues databases tried/try to solve The ingredients of a database The users of a database and their respective roles (look at the later review of the database administrator as well) The data abstraction levels in a database The data models in a database The distinction between instance and schema Data definition versus data manipulation language Data manager program and its functions Overall database system structure

4 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

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) also written: : : ( r R, t1, t2 r : t1[X]=t2[X] : t1[Y]=t2[Y]) basically identical with: :: ( r R, t1, t2 r ::t1[X]=t2[X] t1[Y]=t2[Y])

6 Notations r R indicates instance r is a valid instance for schema R (relation type). t r indicates t is a tuple of r. X R (***) indicates X is a subset of the set of attributes used by R (~ heading). XY means X Y. (***) Should actually be X Attr(R) (heading)

7 To prove or not to prove, that is the question. Given a proposition Q it always holds that Q Q. For example: {De Morgan} ergo Prove or give a counter example

8 Proving To prove a functional dependency we can use the inference rules (Armstrong) or the definition of functional dependency Normally, the choice is optional.

9 Why prove something using definition of FD? Usually we prefer inference rules. However: we must prove that they are correct (hold). – via FD definitions!

10 Ex: Augmentation and Transitivity rules 1.Augmentation: Prove (using the definition of fd) that if X, Y and Z are sets of attributes of a relational schema R, and the fd X Y holds in R, then XZ YZ also holds in R. 2.Transitivity: Prove (using the definition of fd) that if X, Y and Z are sets of attributes of a relational schema R, and the fds X Y and Y Z hold in R, then X Z also holds in R.

11 Augumentation (in short) ( r R, t1, t2 r : t1[X]=t2[X] : t1[Y]=t2[Y]) (this is the definition of X Y) ( r R, t1, t2 r : t1[Z]=t2[Z] : t1[Z]=t2[Z]) (this is always true) (because ((A B) (C D) (A C) (B D)) ( r R, t1, t2 r : t1[X]=t2[X] t1[Z]=t2[Z] : t1[Y]=t2[Y] t1[Z]=t2[Z]) (because for a function t: t[X Z] = t[X] t[Z]) ( r R, t1, t2 r : t1[XZ]=t2[XZ] : t1[YZ]=t2[YZ]) (this is the definition of XZ YZ)

12 Lemma 1 (((A B) (C D)) (A C) (B D)) (use (X => Y) (~X v Y) (twice) and distribute the negation over the conjunction) ~(A B) v ~(C D) v ~(A C) v (B D) (use ~(X => Y) (X ~Y), distribute negation over conjunction) (A ~B) v (C ~D) v ~A v ~C v (B D) (use ((X ~Y) v ~X) (~Y v ~X)) ~A v~B v~C v~D v (B D) (distribute negation over conjunction) ~A v~(B D) v~C v (B D) ( (X v~X) true; true/false elimination) true

13 Augumentation (formal -1) (1)( r R, t1, t2 r ::t1[X]=t2[X] t1[Y]=t2[Y]) (this is the definition of X Y) (2) ( r R, t1, t2 r :: t1[Z]=t2[Z] t1[Z]=t2[Z]) (this is always true) (3)Since both (1) and (2) hold, we can conjugate them: ( r R, t1, t2 r :: t1[X]=t2[X] t1[Y]=t2[Y]) ( r R, t1, t2 r :: t1[Z]=t2[Z] t1[Z]=t2[Z]) (domain splitting) (4)( r R, t1, t2 r :: (t1[X]=t2[X] t1[Y]=t2[Y]) t1[Z]=t2[Z] t1[Z]=t2[Z]))

14 Augumentation (formal -2) (domain splitting) (4)( r R, t1, t2 r :: (t1[X]=t2[X] t1[Y]=t2[Y]) t1[Z]=t2[Z] t1[Z]=t2[Z])) (because of Lemma 1: ((A B) (C D)) ((A C) (B D))) ( r R, t1, t2 r :: (t1[X]=t2[X] t1[Z]=t2[Z]) (t1[Y]=t2[Y] t1[Z]=t2[Z])) (because for a function t: t[X Z] = t[X] t[Z]) ( r R, t1, t2 r :: (t1[XZ]=t2[XZ] t1[YZ]=t2[YZ]) (this is the definition of XZ YZ)

15 Transitivity (1) (1) ( r R, t1, t2 r:: (t1[X]=t2[X]) (t1[Y]=t2[Y])) (definition of X Y) (2) ( r R, t1, t2 r:: (t1[Y]=t2[Y]) (t1[Z]=t2[Z])) (definition of Y Z) Since both (1) and (2) hold, we can conjugate them: ( r R, t1, t2 r :: (t1[X]=t2[X]) (t1[Y]=t2[Y])) ( r R, t1, t2 r :: (t1[Y]=t2[Y]) (t1[Z]=t2[Z])) (domain splitting) ( r R, t1, t2 r ::( t1[X]=t2[X] t1[Y]=t2[Y]) (t1[Y]=t2[Y] t1[Z]=t2[Z]))

16 Transitivity (2) (domain splitting) ( r R, t1, t2 r ::( t1[X]=t2[X] t1[Y]=t2[Y]) (t1[Y]=t2[Y] t1[Z]=t2[Z])) (because of Lemma 2: ((A B) (B C)) (A C)) ( r R, t1, t2 r :: t1[X]=t2[X] t1[Z]=t2[Z]) (this is the definition of X Z)

17 Lemma 2 ((A B) (B C)) (A C) (use (X Y) (~X v Y) and distribute the negation over the conjunction) ~(A v B) v ~(B v C) v (~A v C) (use ~(X Y) (X ~Y), distribute negation over conjunction) (A ~B) v (B ~C) v (~A v C) (use ((X ~Y) v ~X) (~Y v ~X)) ~A v ~B v B v C ( (X v ~X) true; true/false elimination) true

18 Disproving to show a rule does not hold you must find (using your imagination) at least one instance in which the given fds hold and the supposedly implied fds do not hold.

19 Bogus rules 3.Disprove that if X and Y are sets of attributes of a relational schema R, and the fd X Y holds in R, then Y X also holds in R. 4.Disprove that if X, Y and Z are sets of attributes of a relational schema R, and the fds X Y and Y Z hold in R, then Z X also holds in R. 5.Disprove that if X, Y and Z are sets of attributes of a relational schema R, and the fd XY Z holds in R, then X YZ also holds in R.

20 Bogus rules 3 3.Disprove that if X and Y are sets of attributes of a relational schema R, and the fd X Y holds in R, then Y X also holds in R. Solution: Consider the following relation instance, where we use singletons for X and Y: We see that X Y holds, but not Y X XY 10 00

21 Bogus rules 4 Disprove that if X, Y and Z are sets of attributes of a relational schema R, and the fds X Y and Y Z hold in R, then Z X also holds in R. Solution: Consider the following relation instance, where we use singletons for X, Y, and Z: We see that both X Y and Y Z hold But not Z X. XYZ

22 Bogus rules 5 Disprove that if X, Y and Z are sets of attributes of a relational schema R, and the fd XY Z holds in R, then X YZ also holds in R. Solution: Consider the following relation instance where we use singletons for X, Y, and Z: We see that XY Z holds, but not X YZ. XYZ

23 Summary We have learned how to prove & disprove FDs based on the definition

24 … to follow Functional Dependencies (FDs) applied (2)

25 Questions?