Answer Reference

Question 1

List all nontrivial functional dependencies satisfied by the relation of the below figure:

Tuple A B C
1 a b c
2 a b c
3 a b c
4 a b c

Figure. Relation of Exercise

Answer Q1

:::success The nontrivial function dependencies are:
A -> B and C -> B, and
a dependency they logically imply: AC -> B.

C does not functionally determine A because the first and third tuples have the same C but different A values.

The same tuples also show B does not functionally determine A.

Likewise, A does not functionally determine C because the first two tuples have the same A value and different C values.

The same tuples also show B does not functionally determine C.
There are 19 trivial functional dependencies of the form a -> b, where b is included by a.:::

Question 2

Use Armstrong’s axioms to prove the soundness of the union rule.
(Hint: Use the augmentation rule to show that, if  α→β , then α→αβ.
Apply the augmentation rule again, using α→γ, and then apply the transitivity rule.)

Answer Q2

To prove that
TUR09 CISC3000 Tutorial 09 - 图1

Following the hint, we derive:
TUR09 CISC3000 Tutorial 09 - 图2 given
TUR09 CISC3000 Tutorial 09 - 图3 augmentation rule
TUR09 CISC3000 Tutorial 09 - 图4 union of identical sets
TUR09 CISC3000 Tutorial 09 - 图5 given
TUR09 CISC3000 Tutorial 09 - 图6 augmentation rule

TUR09 CISC3000 Tutorial 09 - 图7 transitivity rule and set union communtativity

Question 3

Use Armstrong’s axioms to prove the soundness of the pseudotransitivity rule.

Answer Q3

Proof using Armstrong’s axioms of the Pseudotransitivity Rule:
TUR09 CISC3000 Tutorial 09 - 图8

TUR09 CISC3000 Tutorial 09 - 图9 given
TUR09 CISC3000 Tutorial 09 - 图10 augmentation rule and set union commutativity
TUR09 CISC3000 Tutorial 09 - 图11 given

Result:
TUR09 CISC3000 Tutorial 09 - 图12 transitivity rule

Question 4

Use Armstrong’s axioms to prove the soundness of the decomposition rule.

Answer Q4

The decomposition rule, and its derivation from Armstrong’s axioms are given below:
TUR09 CISC3000 Tutorial 09 - 图13

TUR09 CISC3000 Tutorial 09 - 图14 given
TUR09 CISC3000 Tutorial 09 - 图15 reflexivity rule
TUR09 CISC3000 Tutorial 09 - 图16 transitivity rule
TUR09 CISC3000 Tutorial 09 - 图17 reflexive rule
TUR09 CISC3000 Tutorial 09 - 图18 transitive rule

Result:
1) TUR09 CISC3000 Tutorial 09 - 图19 transitivity rule
2) TUR09 CISC3000 Tutorial 09 - 图20 transitive rule

Question 5

Compute the closure of the following set F of functional dependencies for relation
schema R = (A, B, C, D, E).
A → BC
CD → E
B → D
E → A
List the candidate keys for R.

Answer Q5

  1. schema R = (A, B, C, D, E)
  2. F ={
  3. A BC => A > B, A > C
  4. CD E => A > C, A > D => A > E
  5. B D => A > B, B > D => A > D
  6. E A
  7. }
  8. Prime Attribute: A,E,C,D
  9. (A, B, C, D, E) += {A, B, C, D, E} to
  10. (A, x, x, x, x)
  11. (A) += {A,B,C,D,E}
  12. (E) += {E,A,B,C,D}
  13. (CD) += {C,D,E,A,B}
  14. check (C) += {C}
  15. check (D) += {D}
  16. (BC) += {B,C,D,E,A}
  17. check (B) += {B, D}
  18. check (C) += {C}

The candidate keys are A, BC, CD, and E.

:::success List the candidate keys for R
Ans:
Starting with A > BC, we can conclude: A > B and A > C.
Since A > B and B > D, A > D
(Decomposition transitive)
Since A > CD and CD > E, A > E
(Union, decomposition, Transitive)
Since A > A, we have A > ABCDE from the above steps
(Reflexive and Union)
Since E > A, E > ABCDE
(Transitive)
Since CD > E, CD > ABCDE
(Transitive)
Since B > D and BC > CD, BC > ABCDE
(Augmentative, Transitive)
Also, C > C, D > D, BD > D, etc

Therefore, any functional dependency with A, E, BC, or CD on the left-hand side of the arrow is in F+, no matter which other attributes appear in the FD.

Allow to represent any set of attriubutes in R, then F+ is
BD > B, BD > D,
C > C,
D > D,
BD > BD,
B > D, B > B, B > BD
and all FDs of the form A
> alpha, BC > alpha, CD > alpha, E * > alpha
where alpha is any subset of { A, B, C, D, E }

The candidate keys are A, BC, CD and E. :::

Example

  1. R = {A, B, C, G, H, I}
  2. F = {
  3. A -> B,
  4. A -> C,
  5. CG -> H,
  6. CG -> I,
  7. B -> H
  8. }
  9. (A,B,C,G,H,I) += (A, B, C, G, H, I) to
  10. (A,x,x,G,x,x) += (A, B, C, G, H, I)
  11. (AG) += (A, B, C, G, H, I)

Question 6

Using the following functional dependencies,
compute the canonical cover Fc.

  1. F = FDs {
  2. A BC
  3. CD E
  4. B D
  5. E A
  6. }

Answer Q6

:::success The given set of FDs F is:

  • A > BC => A > B, A > C
  • CD > E
  • B > D
  • E > A

The left side of each FD in F is unique.
Also none of the attributes in the left side or right side of any of the FDs is extraneous 多餘的.
Therefore the canonical cover Fc is equal to F.:::

Example

Suppose that

Extraneous Attributes

  1. F = { AB -> CD, A -> C}
  2. {AB > C, A > D, D > C} - {AB > C} u {A > C}
  3. {AB > CD, A > C} - { AB > CD } u { AB > CD - C}
  4. implies F
  5. F = {
  6. AB -> C,
  7. AB -> D,
  8. A -> C
  9. } -- OK
  10. {
  11. A -> CD, B -> CD, -- Wrong!!
  12. A -> C -- Wrong!!
  13. }
  1. R = {A, B, C}
  2. F = { A > BC, B > C, A > B, AB > C }
  3. { A > B, A > C, B > C, A > B, AB > C }
  4. { A > B, A > C, B > C, AB > C }
  5. -- Remove B in AB > C
  6. { A > B, A > C, B > C, A > C }
  7. { A > B, A > C, B > C }
  8. { A > B, B > C }

Dependency Preservation

  1. F = { AB > CD, A > E, E > C }
  2. = { AB > C, AB > D, A > E, E > C}
  3. = { AB > D, A > E, E > C}
  4. -- Because A > E > C -> A > C & AB > A,
  5. -- del AB > C

Canonical Cover

Example - Dependency Preservation

Question:
Consider schema R(X,Y,Z,W)
and F={ X > Z,Z > X, Y > XZ,W > XZ}that holds on R.
Give the lossless,dependency preserving decomposition of this schema into 3NF

  1. X > Z
  2. Z > X
  3. Y > XZ => Y > X, Y > Z
  4. W > XZ => W > X, W > Z

:::success Ans:
The solution is follows:

  1. Find {YW} += R

(这里有一个确定候选键的原则,首先如果一个属性只出现在了关系式右边,则必定不是,如果只出现在左边,则必定在候选键当中,然后加上别的属性,如果全集等于U,则就是候选键。候选键不只有一个,候选键中不能有冗余)

  1. Calculate the Fc, Minimal Relation 最小關係集

  2. With respect to F = {X > Z, Z > X, Y > XZ, W >XZ},

considering X in Y > XZ and Z in W > XZ,<br />{X > Z, Z > X, Y > Z, W > X} implies F, so X in Y > XZ and Z in W > XZ are all extraneous
(这两个属性在这里是多余的,首先把它们化简掉)

attributes, and one of canonical covers for F is
Fc = {X > Z, Z > X, Y > Z, W > X}
(但不是唯一一個)

  1. 对Fc中的每一个依赖函数 A -> B,都将它变成AB这样一个 subschema

R1 = {XZ}, R2 = {YZ}, R3 = {WX}
由於缺少一個候選鍵,再加上
R4 = {YW}
因此,最後的分解式應該是
{XZ, YZ, WX, YW} :::