Download presentation

Presentation is loading. Please wait.

Published byBritton Stokes Modified about 1 year ago

1
Properties of Armstrong’s Axioms Soundness All dependencies generated by the Axioms are correct Completeness Repeatedly applying these rules can generate all correct dependency (i.e., any FDs in F + be generated)

2
Closure of Attribute Set X Let F be a set of functional dependencies on a set of attributes U and let X U. We define X + to be the set of all attributes that are dependent on X (under F). X + enables us to tell at a glance whether a dependency X A follows from F.

3
Algorithm to compute X + under F // initialization 1.X + := X; // reflexive rule // find new attribute 2.For each function dependency Y Z in F, if Y X + and Z has an attribute not in X +, add the new attribute to X+; //transitive rule 3.Repeat Step 2 until no new attribute can be found R(A,B,C,D,E,F), F={A->D, B->E, D B, C->F}, What is {A} +? Example 1

4
Closure of Attribute Set: Example 2 EMP_PROJ(SSN,PNUMBER,HOURS,ENAME,PNAME,PLOCATION) F={ { SSN}->{ENAME}, { PNUMBER}->{PNAME,PLOCATION}, {SSN,PNUMBER} {HOURS} } Initialization:{SSN} + ={SSN} 1 st iteration: SSN->ENAME, ENAME to is a new attribute {SSN} + ={SSN,ENAME} 2 nd iteration: {SSN} + ={SSN,ENAME}, cannot find any new attribute (1) Compute {SSN} +

5
(2) Compute {PNUMBER} + Initialization:{PNUMBER} + ={PNUMBER} 1 st iteration: {PNUMBER} -> {PNAME,PLOCATION} {PNUMBER} + ={PNUMBER,PNAME,PLOCATION} 2 nd iteration: cannot find any new attribute {PNUMBER} + ={PNUMBER,PNAME,PLOCATION} (3) Compute {SSN, PNUMBER} + F={ {SSN}->{ENAME}, {PNUMBER}->{PNAME,PLOCATION}, {SSN,PNUMBER} {HOURS} }

6
Steps of checking if an FD X Y is in the closure of a set of FDs F : 1.Compute X + wrt F. 2.Check if Y is in X +. 3.Y X + X Y is in F + Does F = {A B, B C, CD E } imply A E? i.e, is A E in F + ? Equivalently, is E in A + ? A + (w.r.t. F)={A,B,C} E is not in A +, thus, A E is not in F +. Use of X + 1: Checking if X Y

7
Set K:=R For each attribute A in K Compute (K-A) + w.r.t. F If (K-A) + contains all the attributes in R then set K:= K-A This algorithm returns only one key out of the possible candidate keys for R. The key returned depends on the order in which attributes are removed from R. Examples: (1) R={A,B,C,D} F={A B,B C,AB D}; find a key of R. (2) R={A,B,C,D,E,F} F= {A->C, A->D, B->C, E->F}; find a key of R Use of X + 2: Finding a key K Let R be the set of attributes for a schema and F be its functional dependency set

8
Given a set of functional dependencies F, we define F + to be the set of all functional dependencies that can be inferred from F. Use of X + 3: Compute F + 1.F + ={}; 2.For each attribute set A in R, computing A + 3.For each X Y implied by A +, add X Y to F+

9
Equivalence of Sets of Functional Dependencies Let E&F be two sets of functional dependencies. F covers E if E F +. E and F are equivalent if E + =F +. E + =F + iff E covers F and F covers E. Note: Equivalence means that every FD in E can be inferred from F, and every FD in F can be inferred from E. Determine whether F covers E: For each FD X Y in E, calculate X + with respect to F, then check whether X + Y.

10
EXAMPLE: Check whether or not F is equivalent to G. F={A C, AC D, E AD,E H} G={A CD, E AH} Prove that F is covered by G. {A} + ={A,C,D} (wrt to G). Since {C} A +, A C can be inferred from G. {AC} + ={A,C,D} (wrt to G). Since {D} {AC} +, AC D is covered by G. {E} + ={E,A,H,C,D} (wrt G), Since {AD} {E} +, E AD is covered by G. Since {H} {E} +, E H is covered by G.

11
Prove that G is covered by F: {A} + ={A,C,D} (wrt F), Since {CD} {A} +, A CD is covered by F. {E} + ={E,A,D,H,C} (with respect to F) {A,H} {E} +, E AH is covered by F. Since F covers G and G covers F, F and G are equivalent. F={A C, AC D, E AD,E H} G={A CD, E AH}

12
Minimal Cover of Functional Dependencies A set of functional dependencies F is minimal if it satisfies the following three conditions: Every FD in F has a single attribute for its right-hand side. (This is a standard form, not a requirement.) We cannot replace any dependency X A in F with a dependency 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 dependencies that is equivalent to F. There can be several minimal covers for a set of functional dependencies!

13
Minimal Cover Definition: A minimal cover of a set of FDs F is a minimal set of functional dependencies F min that is equivalent to F. /* The following procedure finds one minimal cover of F. */ Procedure: Find a minimal cover F min for F. 1.Set F min =F /*put every FD in a standard form, i.e., it has a single attribute as its right-hand side*/ 2.Replace each FD X A 1,A 2,…,A n in F min by the n FDs X A 1,…,X A n. /* minimize the left side of each FD, i.e., every attribute is needed */ 3.For each FD X A in F min For each B X, Let T=(F min - {X A})U{(X-{B}) A} Check whether T is equivalent to F min (1) If (1) is true, then set F min = T. /* delete redundant FDs, i.e., No redundant FDs remain in Fmin. */ 4.For each FD X A in F min Let T=F min -{X A} Check whether T is equivalent to F min. (2) If (2) is true, set F min = T.

14
Minimal Cover F={X1 Y1, X2 Y2, … Xn Yn} is a minimum cover 1)Any Yi is a single attribute 2)For any Xi Yi, it is impossible that X’ Y and X’ is a subset of X 3)No Xi Yi can be taken out F’ = F - {Xi Yi} is not equivalent to F

15
Example: Find the minimal cover of the set F={ABCD E,E D,A B,AC D}.

16
Example: Find the minimal cover of the set F={ABCD E,E D,A B,AC D}. Step 2:F min ={ABCD E,E D,A B,AC D} Step 3: Replace AC D with A D; T={ABCD E,E D,A B,A D} Compute {A} + wrt to F, {A} + ={A,B} Compute {A} + wrt to T, {A} + ={A,B,D} Cannot replace F min with T. Replace ABCD E with ACD E, T={ACD E,E D,A B,AC D} Compute {ACD} + wrt to F, {ACD} + ={A,C,D,B,E} Compute {ACD} + wrt to T,{ACD} + ={A,C,D,E,B} Replace F min with T. Is T equivalent to F min ? Can Fmin Cover T? No, keep AC D

17
Step 3: (cont’d) Replace ACD E with AC E, T={AC E,E D,A B,AC D} Compute {AC} + wrt to F, {AC} + ={ACDBE} Compute {AC} + wrt to T,{AC} + ={ACEDB} Replace F min with T. Step 4: Consider T={AC E,E D,AC D,A B} (take out AC D) {AC} + ={A,C,E,D,B} with respect to T; {D} {AC} + ; we don’t have to include AC D The minimal cover of F is: {AC E,E D,A B}

18
Some Important Concepts X + : Closure of an attribute set X –The set of all attributes that are determined by X K: a key –minimum set of attributes that determines all attributes F + : Closure of a dependency set F –The set of all dependencies that are implied from F F min : a minimum cover of a dependency set F –a minimum set of FDs that is equivalent to F

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google