MSDN Documentation

Functional Dependencies

Functional dependencies (FDs) are a fundamental concept in relational database design. They describe the relationship between attributes (columns) in a relation (table). Understanding FDs is crucial for achieving database normalization, which helps reduce data redundancy and improve data integrity.

Definition

A functional dependency, denoted as X → Y, states that for any two tuples (rows) r1 and r2 in a relation R, if r1[X] = r2[X], then it must be that r1[Y] = r2[Y]. In simpler terms, the value(s) of attribute(s) in set X uniquely determine the value(s) of attribute(s) in set Y.

Types of Functional Dependencies

Functional dependencies can be categorized based on the attributes involved:

Inference Rules (Armstrong's Axioms)

Armstrong's axioms are a set of rules that allow us to infer all valid functional dependencies from a given set of FDs. These rules are complete, meaning any FD that logically follows from a set of FDs can be derived using these axioms.

  1. Reflexivity: If Y ⊆ X, then X → Y. (Trivial FDs)
  2. Augmentation: If X → Y and W is any set of attributes, then XW → YW.
  3. Transitivity: If X → Y and Y → Z, then X → Z.

From these three, we can derive others:

Example

Consider a relation Students with attributes: {StudentID, StudentName, CourseID, CourseName, InstructorID, InstructorName}.

Suppose we have the following functional dependencies:

Analysis:

Let's look for potential issues related to normalization:

Consider the FD {StudentID, CourseID} → InstructorID. If we can determine InstructorID from StudentID alone, or from CourseID alone, then this is a partial dependency.

Suppose we also know that StudentID → InstructorID. This would be a partial dependency because InstructorID is determined by only part of the composite key {StudentID, CourseID}.

Now, consider the FD StudentID → InstructorName. We know StudentID → InstructorID and InstructorID → InstructorName. By transitivity, we can infer StudentID → InstructorName. Since StudentID is not a superkey for the whole relation, this represents a transitive dependency.

Importance in Normalization

Functional dependencies are the bedrock of database normalization:

By analyzing and enforcing functional dependencies, we can systematically normalize a database schema to achieve optimal structure.