Functional Dependencies
A relationship between two sets of attributes in a relational database. Denoted as X → Y
. A generalization of a key. Means that for any two rows in a table, if the values of attributes in set X
are the same, then the values of attributes in set Y
must also be the same. In other words, the value of X
uniquely determines the value of Y
.
Functional dependencies are fundamental to understanding how data is organized and how redundancy can be minimized. They are used to guide the process of normalization, which helps ensure that the database structure is efficient and free from undesirable anomalies.
Consider a table with attributes StudentID
, StudentName
, and Major
. If each StudentID
is unique and always refers to the same StudentName
, then there is a functional dependency:
StudentID → StudentName
Functional dependencies help identify candidate keys and are essential for designing robust relational schemas.
Trivial
A functional dependency is trivial if it is satisfied by all instances of a relation. Of the form where .
Legal instance
For a relation: An instance of a relation that satisfies all real-world constraints.
If a relation is legal under set of functional dependencies , it’s mentioned as satisfies .
For a database: an instance of a database in which all the relations are legel.
If a set of functional dependencies is legal under a relation schema , it’s mentioned as holds on .
Closure
Suppose a set of functional dependencies . The set of all functional dependencies logically implied by . Superset of . Denoted by .
Armstrong’s axioms
Closure of can be found by repeatedly applying Armstrong’s axioms.
- Reflexivity: If then
- Augmentation: If then
- Transitivity: If and and
The above rules are:
- sound - generate functional dependencies that hold
- complete - generate all functional dependencies that hold
Other inferred rules:
- union: If and then
- decomposition: If then and
- pseudotransitivity: If and then
Superkey
is a superkey for a relation schema iff .
Candidate key
is a candidate for a relation schema iff and is minimal.