Dulranga's Notes
Semester 3Database Systems

Functional Dependancies

These describe a relationship between attributes (columns) in a table. So we can think of these as relationships inside same table. This is the main component we need to do database normalizations and avoid huge messy tables and make consistent smaller simpler tables.

Notation

X→YX \rightarrow Y

This means XX determines YY.

  • XX - Determinant
  • YY - Dependent

Rule 1

Right Side depends on Left Side.

If XX is given, YY must be only one possible value nothing else.

Rule 2

Multiple Determinants (XX) can share same YY value, but one XX can have only ONE YY value.

Important

Simply ask, If I know XX, can I tell YY?

  • if its yes, functionally dependent.
  • otherwise not.

Armstrong's Axioms

These are a set of axioms like in Boolean Algebra, we use to combine different functional dependancies to find hidden relationships. These are useful to further normalize a database.

armstrong-axioms.png

Reflexivity

If YY is inside XX, then X→YX \rightarrow Y

  • eg: {Name,Age}→Name\{\text{Name}, \text{Age}\} \rightarrow \text{Name}

Augmentation

If X→YX \rightarrow Y, you can add ZZ to both sides: XZ→YZXZ \rightarrow YZ.

  • eg: Emp_ID→Salary\text{Emp\_ID} \rightarrow \text{Salary}, then {Emp_ID,Dept}→{Salary,Dept}\{\text{Emp\_ID}, \text{Dept}\} \rightarrow \{\text{Salary}, \text{Dept}\}.

Transitivity

If X→YX \rightarrow Y and Y→ZY \rightarrow Z, then X→ZX \rightarrow Z.

  • eg: Zip_Code→City\text{Zip\_Code} \rightarrow \text{City}, and City→State\text{City} \rightarrow \text{State}, so Zip_Code→State\text{Zip\_Code} \rightarrow \text{State}.

Derived Axioms (Shortcuts)

Union

If X→YX \rightarrow Y and X→ZX \rightarrow Z, then X→YZX \rightarrow YZ.

Decomposition

If X→YZX \rightarrow YZ, then X→YX \rightarrow Y and X→ZX \rightarrow Z.

Pseudo Transitivity

If X→YX \rightarrow Y  and YZ→WYZ\rightarrow W , then XZ→WXZ\rightarrow W

Attribute Closure (X+X^+)

These are useful to determine if a attribute set is a candidate key or a given functional dependency holds.

Note

Attribute closure is a set of attributes (X+X^+) such that, if I know the set of attributes XX, I can determine all attributes present in X+X^+

X→X+X \rightarrow X^+ - This is Always true for all attributes in XX

Algorithm

  1. Initialize X=X+X = X^+
  2. Search for any dependency U→VU \rightarrow V in FF where UU is in X+X^+ but VV is not
  3. Add VV to X+X^+
  4. Repeat until no new attributes can be added

If X+X^+ includes all attributes of a relation RR, then XX is a super key of RR

Functional Dependency Closure (F+F^+)

This is the set of all possible functional dependencies that can be logically derived from the functional dependency set FF

Used to evaluate equivalence between sets of dependencies and determine schema normalization (e.g., 3NF, BCNF)

Attribute Closure (X+)Dependency Closure (F+)
What it containsAttributes / Columns (e.g., {A,B,C}\{A, B, C\})Functional Dependencies / Rules (e.g., {A→B,A→C}\{A \rightarrow B, A \rightarrow C\})
InputA specific set of attributes XX and rules FFA set of functional dependencies FF
Core Question"What attributes can XX uniquely determine?""What are all valid rules that logically follow from FF?"
Size & ComputationSmall, fast to compute (linear/polynomial time)Huge, exponential in size (computing F+F^+ directly is computationally expensive)

On this page