There are usually a variety of constraints on the data in the real world.

An instance of a relation that satisfies all such real-world constraints is called a legal instance of the relation; a legal instance of a database is one where all the relation instances are legal instances.

Some of the most commonly used types of real-world constraints can be represented formally as keys (superkeys, candidate keys, and primary keys), or as functional dependencies.

Definition

Consider a relation schema , and let be sets of attributes.

Given an instance of , the instance is said to satisfy a functional dependency if for all pairs of tuples and in the instance,

The functional dependency is said to hold on schema if every legal instance of satisfies the functional dependency.

One easy way to understand the concept of functional dependency is to interpret as:

If values of is given, then values of is uniquely determined.

Trivial functional dependencies

A functional dependency is trivial if it is satisfied by all instances of a relation.

In general, is trivial if .

Keys and functional dependencies

  • is a superkey for relational schema if and only if the functional dependency holds on .
  • is a candidate key for if and only if the functional dependency holds on , and for any , .

Use of functional dependencies

Functional dependencies can be used to:

  • Test relations to see if they are legal inder a given set of functional dependencies
  • Specify constraints on the set of legal relations

Note that a specific instance of a relation schema may satisfy a functional dependency even if the functional dependency does not hold on all legal instances.

  • e.g., A specific instance of instructor may, by chance, satisfy