Sub topic 9
Functional Dependencies and Armstrong's Axioms
Prerequisites and the Working Model
Assume you know basic set notation, tables, rows, columns, and introductory SQL. A functional dependency (FD) is a rule about valid rows in a relation. We write:
X -> Y
This means that if two rows agree on every attribute in X, they must also agree on every attribute in Y. Therefore, X determines Y. The rule applies to the relation as a whole, not just to the rows currently stored.
For example, in ENROLLMENT(StudentID, CourseID, Grade), the pair {StudentID, CourseID} determines Grade:
{StudentID, CourseID} -> Grade
A student can receive only one grade for a particular course. However, StudentID -> Grade is usually false because one student can receive different grades in different courses.
Types of Dependencies
An FD is trivial when its right side is already part of its left side. For example, {A, B} -> A is always true. An FD is nontrivial when the right side contains an attribute not present on the left.
A set of FDs describes the assumptions made about a relation. These assumptions help identify keys and detect redundancy. A primary key determines every attribute in its table, but other determinants may also exist.
| Dependency | Meaning |
|---|---|
| `A -> B` | A value identifies one B value |
| `AB -> C` | The combination of A and B identifies C |
| `AB -> A` | Trivial dependency |
| `A -> BC` | A determines both B and C |
Armstrong's Axioms
Armstrong's axioms are sound and complete inference rules for FDs. Sound means every derived dependency is valid whenever the original dependencies are valid. Complete means every dependency logically implied by the original set can be derived using these rules.
- Reflexivity: If
Yis a subset ofX, thenX -> Y. - Augmentation: If
X -> Y, thenXZ -> YZfor any attribute setZ. - Transitivity: If
X -> YandY -> Z, thenX -> Z.
Several useful rules follow from these axioms:
- Union: If
X -> YandX -> Z, thenX -> YZ. - Decomposition: If
X -> YZ, thenX -> YandX -> Z. - Pseudotransitivity: If
X -> YandWY -> Z, thenWX -> Z.
Do not confuse an FD with a correlation. If data currently shows one department for each employee, that does not prove EmployeeName -> Department. The rule must be guaranteed by the meaning of the data.
CREATE TABLE enrollment (
student_id INTEGER,
course_id INTEGER,
grade TEXT,
PRIMARY KEY (student_id, course_id)
);The primary key expresses that {student_id, course_id} identifies one enrollment row and therefore determines its grade.
Exercise
Given A -> B and B -> C, which Armstrong axiom derives A -> C?
Show answer
Transitivity derives A -> C.