Download presentation

Presentation is loading. Please wait.

Published byKathryn Carpenter Modified about 1 year ago

1
Database Management COP4540, SCS, FIU Functional Dependencies (Chapter 14)

2
Database Management COP4540, SCS, FIU What are functional dependencies A FD is a constraint between two sets of attributes from the database.. A FD, denoted by X Y, between two sets of attributes X and Y forms a constraint that states: –For any two tuples t 1 and t 2 such that t 1 [X] =t 2 [X], we much also have t 1 [Y] =t 2 [Y]. –The values of the Y component of a tuple depend on, or are determined by, the values of X component.

3
Database Management COP4540, SCS, FIU Example Employee(SSN, EName) Project(ProjectNo, ProjectName, DeptName) WorksOn(SSN, ProjectNo, Hours) Functional dependencies: SSN Ename ProjectNo ProjectName DeptName SSN ProjectNo Hour

4
Database Management COP4540, SCS, FIU Additional Notes A functional dependency is a property of the semantics or meaning of the attributes. A functional dependency is a property of the relation schema R, not of a particular legal relation state r of R. –FD cannot be inferred from a given relation state. –It must be defined explicitly by someone who knows the semantics of the attributes of R.

5
Database Management COP4540, SCS, FIU Keys and FDs A key is a determinant, while a determinant may or may not be a key. A key is always unique to the relation, while a determinant may or may not be unique to the relation. The most significant difference between keys and FDs is UNIQUENESS and MINIMALITY. Several terms: –Superkey –Candidate Key –Primary Key

6
Database Management COP4540, SCS, FIU Example Student(SSN, Name, Phone, City, Street, Zip) SSN Phone Name City Street Zip SSN Name City Street Zip City Street Zip

7
Database Management COP4540, SCS, FIU Example EMP_DEPT EMP_PROJ

8
Database Management COP4540, SCS, FIU Computing the Closure of Attributes What is the closure of attributes? –Given a set of attributes A = {A 1, A 2, …, A n } and a set of FDs S, the closure of A under the FDs in S is the set of attributes B such that every relation that satisfies all the FDs in S also satisfies A 1, A 2, …, A n B. –B is denoted by A + = {A 1, A 2, …, A n } + How to compute a closure? Algorithm: Determining X +, the closure of X under F X + = X; repeat oldX + = X + ; for each FD Y Z in F do if Y X + then X + = X + Z; until ( oldX + = X + );

9
Database Management COP4540, SCS, FIU Let us consider a relation with attribute A, B, C, D, E and F. Suppose that this relation has the functional dependencies AB C, BC AD. D E, and CF B. 1. What is the closure of {A, B}, that is {A,B} + ? 2. How to test whether AB D follows from these dependencies? How about D A? 3. What can be the primary key of this relation? Example

10
Database Management COP4540, SCS, FIU Splitting/Combing Rule Splitting rule A FD A 1 A 2 … A n B 1 B 2 … B m can be replaced by a set of FDs A 1 A 2 … A n B i for i = 1, 2, …, m. Combining rule A set of FDs A 1 A 2 … A n B i for i = 1, 2, …, m can be replaced by a single FD A 1 A 2 … A n B 1 B 2 … B m

11
Database Management COP4540, SCS, FIU Trivial-dependency Rule A FD A 1 A 2 … A n B 1 B 2 … B m is –Trivial if the B’s are a subset of the A’s. –Nontrivial if at least one of the B’s is not among the A’s. –Completely nontrivial if none of the B’s is also one of the A’s. Trivial-dependency rule The FD A 1 A 2 … A n B 1 B 2 … B m is equivalent to A 1 A 2 … A n C 1 C 2 … C k, where the C’s are all those B’s that are not also A’s

12
Database Management COP4540, SCS, FIU The Transition Rule If two FDs A 1, A 2, …, A n B 1, B 2, …, B m and B 1, B 2, …, B m C 1, C 2, …, C k hold in relation R, then A 1, A 2, …, A n C 1, C 2, …, C k also holds in R. This rule can be proved by computing the closure of {A 1, A 2, …, A n } under {A 1, A 2, …, A n B 1, B 2, …, B m B 1, B 2, …, B m C 1, C 2, …, C k }.

13
Database Management COP4540, SCS, FIU A complete Set of Inference Rules Armstrong’s axioms (1974) –Reflexivity if X Y then X Y –Augmentation {X Y} XZ YZ –Transitivity {X Y, Y Z} X Z

14
Database Management COP4540, SCS, FIU Other rules Decomposition ( or projective) rule – { X YZ} X Y Union ( or additive) rule –{X Y, X Z} X YZ Pseudotransitive rule –{X Y, WY Z} WX Z

15
Database Management COP4540, SCS, FIU Proof 1. X--->YZ (given) YZ ---> Y ( using Reflexivity) X ---> Y ( applying transitivity to the above two FDs) 2. X ---> Y (given) X----> Z (given) X ----> XY (applying augmentation to rule 1) XY --> YZ (applying augmentation to rule 2) X ---> YZ ( applying transitivity to the above two rules) 3. X ---> Y (given) WY ---> Z (given) WX ---> WY ( using augmentation to rule 1) WX ---> Z (applying transitivity to rule 2 and 3)

16
Database Management COP4540, SCS, FIU Equivalence of Sets Dependencies Given two sets of dependencies E and F, the closures of these two sets are E + and F + respectively, We say –E is covered by F, if E F +. –E and F are equivalent if E + = F +. –How to determine the equivalence? calculating X + under F for each FD X Y in E, and then checking whether this X + includes the attributes in Y. (This is to determine whether E is covered by F) determining whether F is covered by E by the same approach above.

17
Database Management COP4540, SCS, FIU Example E = {A B, B A, B C, C A} F = {A B, B C, C A }

18
Database Management COP4540, SCS, FIU Minimal Sets of FDs A set of FDs F is minimal if it satisfies the following condition: –Every FD in F has a single attribute for its right-hand side. –We cannot replace any FD X A with a FD Y A, where Y is a proper subset of X, and still have a set of dependencies that is equivalent to F. –We cannot remove any dependency from F and still have a set of FDs that is equivalent to F. A minimal basis of F is denoted by F min, and there may be several minimal bases for one particular F.

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google