Functional Dependencies

Chapter 7 · a functional dependency (FD) describes a relationship between attributes of a relation: the value of one attribute (or set of attributes) uniquely determines the value of another attribute. Everything in normalization is built on FDs.

Formal definition

X → Y

This means: if two rows have the same value of X, then they must also have the same value of Y.

  • X is called the determinant attribute
  • Y is called the dependent attribute
However, this dependency does not mean Y → X. Functional dependency is one-directional.

Example

Student_IDStudent_NameProgram
101RahimCSE
102KarimEEE
103RahimCSE
Holds:
Student_ID → Student_Name
because each Student_ID determines exactly one Student_Name.

Student_ID → Program
because each Student_ID determines exactly one Program.

So we can write: Student_ID → Student_Name, Program
Does NOT hold:
Student_Name → Student_ID

This may not be true, because two students can have the same name — look at rows 101 and 103: both are called Rahim but they are different students.

Practice — find the FDs

FD1smallFor the given table, what are the functional dependencies?
Instructor(instructor_id, name, dept, salary)

Why functional dependency is important

Functional dependency is used in database normalization. It helps to:

  • remove data redundancy;
  • avoid update, insert and delete anomalies;
  • identify candidate keys;
  • decompose tables into better designs.

Vocabulary you will need in the next pages

TermMeaning
Determinantthe left-hand side X of X → Y
Super keyany attribute set that determines every attribute of the relation
Candidate keya minimal super key
Prime attributean attribute that is part of any candidate key
Non-prime attributean attribute that belongs to no candidate key
Partial dependencya non-key attribute depends on only part of a composite key → breaks 2NF
Transitive dependencya non-key attribute depends on another non-key attribute → breaks 3NF

Next: Why normalize? →