Skip to content
Part IA Michaelmas Term

Mathematical Relations

Codd’s radical idea

In the 1970s, Edgar Codd proposed a simple but powerful idea: give users a model of data and a language for manipulating that data which is completely independent of the details of its representation and implementation. This model is based on mathematical relations.

By separating the logical view of data from the physical storage, Codd’s relational model decouples development of the DBMS from the development of database applications. Users query the database in terms of the relations they see; the DBMS decides how to execute those queries on whatever storage structures it uses internally.

Cartesian products

Let SS and TT be sets. The Cartesian product of SS and TT is:

S×T={(s,t)sS,tT}S \times T = \{(s, t) \mid s \in S, t \in T\}

That is, the set of all ordered pairs where the first element comes from SS and the second from TT.

Example.

{A,B}×{3,4,5}={(A,3),(A,4),(A,5),(B,3),(B,4),(B,5)}\{A, B\} \times \{3, 4, 5\} = \{(A, 3), (A, 4), (A, 5), (B, 3), (B, 4), (B, 5)\}

Six pairs total, since S×T=S×T=2×3=6|S \times T| = |S| \times |T| = 2 \times 3 = 6.

Binary relations

A binary relation over S×TS \times T is any set RR with:

RS×TR \subseteq S \times T

That is, a relation is simply a subset of the Cartesian product. In the example above, one possible relation is:

R={(A,3),(B,4),(B,5)}R = \{(A, 3), (B, 4), (B, 5)\}

This particular RR contains three of the six possible pairs. There is no requirement that every element of SS or TT appears in RR, nor that any particular pairing pattern holds.

Domains and database relations

In database parlance, the sets SS and TT are referred to as domains. A domain is the set of all possible values that a given column may take (the type of the column).

We are interested in finite relations RR that are explicitly stored in the database. This distinguishes database relations from mathematical relations studied in logic, such as those arising from integer linear programming constraints, where relations may be infinite or defined by a predicate rather than explicitly enumerated.

Why finite relations?

A database stores a finite number of rows. The relational model is grounded in set theory, but the sets we work with are finite and explicit — we can inspect every tuple, insert and delete tuples, and compute results by applying operations to the tuples themselves. The theory of relational algebra (covered in later notes) relies on relations being sets of known tuples.

Summary

  • Codd’s relational model separates the logical model of data from physical implementation.
  • A Cartesian product S×TS \times T is the set of all ordered pairs from SS and TT.
  • A binary relation over S×TS \times T is any subset RS×TR \subseteq S \times T.
  • In databases, SS and TT are called domains; relations are finite and explicitly stored.