Skip to content
PostDatabase Management System / RDBMS

08-Relational-Database-Design-Functional-Dependency

2023-11-03
Back to Blog

Relational-Database-Design-Functional-Dependency ​

Functional dependencies are some constraints on the set of legal relations. The constraint is that the value for a certain set of attributes uniquely determines the value for another set of attributes. 约束条件是一组属性的值唯一确定另一组属性的值 A functional dependency is a generalization of the notion of a key. 功能依赖关系是键概念的泛化

Functional Dependency Property 功能依赖 ​

  • K is a super key for relation schema iff K→R

  • K is a condidate key for R iff K→R and for no α∉K,α→R

  • Functional dependencies can express constraints that cannot be expressed using superkeys. For example:

courseinfo=(c_name,p_code―,credits,domain,c_number)

We can use functional dependency to hold

c_name→credits

But would not expect the following to hold:

credits→c_name

  • we can use functional dependency to specify constraints on the set of legal relations

  • Trivial A functional dependency is trivial if it is satisfied by all instances of a relation. Equivalently, If $\beta \subseteq \alpha $, then α→β is trivial. Example: (credits,domain,c_number→c_number)(c_name→c_name)

Closure of a Set of Functional Dependencies 功能依赖的闭包 ​

The set of all functional dependencies logically implied by F is the closure of F, denoted by F+.

F+ is a superset of F.

How to find F+ ​

  • Applying Armstrong's Axioms
    1. reflexivity
      • if β⊆α, then α→β
    2. augumentation
      • if α→β, then γα→γβ for any γ.
    3. transitivity
      • if α→β and β→γ, then α→γ.
  • These rules are sound and complete.

This method is also apply in Attribute Closure.

Prove Armstrong's Axioms ​

For Union: If $\alpha \rightarrow \beta $ and α→γ, then α→γβ

  1. α→β
  2. αα→αβ According to augmentation
  3. α→αβ
  4. α→γ
  5. αβ→γβ
  6. α→αβ→βγ According to transitivity
  7. α→βγ

For Decomposition: if α→βγ, then α→β and α→γ

  1. α→βγ
  2. βγ→β according to reflexivity
  3. βγ→γ according to reflexivity
  4. ∴α→β,α→γ according to transitivity

For pseudotransitivity if α→β and γβ→ϵ then αγ→ϵ

  1. ∵α→β
  2. ∴αγ→βγ according to augmentation
  3. ∵αγ→βγ→ϵ according to transitivity
  4. ∴αγ→ϵ