← back to databases

The Relational Model

Wikipedia · wpRelational model · CC BY-SA 4.0

A relation is a set of tuples that all share the same attributes. In everyday terms: a table where every row has the same columns. wpEdgar Codd proposed this model in 1970, replacing navigational databases with pure set theory. Everything in relational databases follows from this one idea.

id (key) name email 1 Alice alice@db.io 2 Bob bob@db.io 3 Carol carol@db.io 4 Dave dave@db.io A relation: set of tuples with a primary key.

Relations, tuples, and attributes

A relation is a named set of tuples. Each tuple is an ordered collection of attribute values. Each attribute has a name and a domain (the set of allowed values). The schema defines the attribute names and domains. The instance is the current set of tuples.

Scheme

Keys

A superkey is any set of attributes that uniquely identifies a tuple. A candidate key is a minimal superkey (remove any attribute and it stops being unique). The primary key is the candidate key chosen to identify rows. A foreign key references the primary key of another relation, creating links between tables.

Scheme

Codd's rules

In 1985, Codd published twelve rules (numbered 0 through 12) that a database must satisfy to be considered fully relational. The key ones: all data is represented as values in tables (Rule 1). Null values represent missing data uniformly (Rule 3). The database description is stored in the same relational structure as ordinary data (Rule 4). There is a comprehensive data sublanguage (Rule 5, fulfilled by SQL).

Scheme
Neighbors

Cross-references

Foundations (Wikipedia)