Download presentation
Presentation is loading. Please wait.
1
1 Design Theory
2
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: X + = { A | F X A} We would like to compute X + Note: We use the symbol, not the symbol. Is there a difference? Closure of a Set of Attributes |=|= |=|= |_|_
3
3 Algorithm From Class Compute Closure(X, F) 1.X + := X 2.While there if a V W in F such that V X + W X + X + := X + W 3. Return X + Complexity: |U|*|F|
4
4 A More Efficient Algorithm We start by creating a table, with a row for each FD and a column for each attribute. The table will have 2 additional columns called size and tail. In the row for a dependency X Y, there will be the value true in each column corresponding to an attribute in X. The size column will contain the size of the set X. The tail column will contain Y.
5
5 Example Table F = {A → C, B → D, AD → E} ABCDESizeTail A → C 1 C B → D 1 D AD → E 2 E
6
6 Compute Closure(X, F, T) /* T is the table */ X + := X Q := X While Q is not empty A := Q.dequeue() for i=1..|F| if T[i, A]=true then T[i,size] := T[i, size] –1 if T[i,size]=0, then –X + := X + T[i,tail] –Q := Q T[i,tail]
7
7 Computing AB + ABCDESizeTail A → C 1 C B → D 1 D AD → E 2 E Start: X + = {A,B}, Q = {A, B}
8
8 Computing AB + ABCDESizeTail A → C 0 C B → D 1 D AD → E 1 E Iteration of A: X + = {A,B,C}, Q = {B,C}
9
9 Computing AB + ABCDESizeTail A → C 0 C B → D 0 D AD → E 1 E Iteration of B: X + = {A,B,C,D}, Q = {C,D}
10
10 Computing AB + ABCDESizeTail A → C 0 C B → D 0 D AD → E 1 E Iteration of C: X + = {A,B,C,D}, Q = {D}
11
11 Computing AB + ABCDESizeTail A → C 0 C B → D 0 D AD → E 0 E Iteration of D: X + = {A,B,C,D,E}, Q = {E}
12
12 Computing AB + ABCDESizeTail A → C 0 C B → D 0 D AD → E 0 E Iteration of E: X + = {A,B,C,D,E}, Q = {}
13
13 Complexity? To get an efficient algorithm, we assume that there are pointers from each “true” box in the table to the next “true” box in the same column. ABCDESizeTail A → C 1 C B → D 1 D AD → E 2 E
14
14 Complexity The complexity of the algorithm is |F| using the pointers We have to prove that the algorithm is sound. We also have to prove it is complete. There are 2 different ways: –Show that if F X A, then A is in the set returned by the algorithm |=|= |_|_
15
15 Proof of Correctness We will prove that the algorithm from the class is sound and complete. The more efficient algorithm here clearly computes the same set. We use X (j) to denote the value in X + at the end of the j-th iteration of the while loop.
16
16 Soundness We will show by induction on j that if A is in X (j), then F X A, using Armstrong’s axioms Basis (j=0): Then A is in X, so by reflectivity, F X A Induction: Suppose X (j-1), only contains attributes B such that F X B. Suppose that A is added to X (j) because of a dependency V W in F. Then, V X (j-1) and A is in W. Then, F X V. Thus, F X W and F X A. |_|_ |_|_ |_|_ |_|_ |_|_ |_|_
17
17 Completeness This can be shown in the same manner that we proved the completeness of Armstrong’s axioms. Formally, we show that if A is not in X +, computed by the algorithm, then there is a relation instance in which all of F hold, but X A does not hold.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.