Relation

A relation is a set of tuples which share the same attribute names.

In other words, if r is a relation then (t1∈r and t2∈r) ⇒ (dom(t1) = dom(t2)).

For example:

    {
        { (S#, S1), (SNAME, Smith), (STATUS, 20), (CITY, London) },
        { (S#, S2), (SNAME, Jones), (STATUS, 10), (CITY, Paris) },
        { (S#, S3), (SNAME, Blake), (STATUS, 30), (CITY, Paris) },
        { (S#, S4), (SNAME, Clark), (STATUS, 20), (CITY, London) },
        { (S#, S5), (SNAME, Adams), (STATUS, 30), (CITY, Athens) }
    }

Since relations are sets we inherit operations from set theory, such as equality (=), inequality (≠), subset (⊆), strict subset (⊂), superset (⊇), strict superset (⊃), union (∪), intersection (∩), difference (\) and membership (∈).

Unlike many authors, we have not formalised a relation as having a heading and a body. Therefore there is only one empty relation (i.e. which has no tuples). In our formalism the empty relation is the empty set. Some authors call this relation DUM.

DUM has no attributes. There is a another relation with no attributes which some authors call DEE. DEE has one tuple.

Visual representation of a relation with a table

A relation is often displayed using a table:

SNOSNAMESTATUSCITY
S1Smith20London
S2Jones10Paris
S3Blake30Paris
S4Clark20London
S5Adams30Athens

The rows of the table correspond to the tuples, and the columns correspond to the attributes.

It should be kept in mind that a relation is defined mathematically in terms of set theory and there is no order defined on the tuples in the relation, or on the attributes in each tuple. By contrast a table has an order defined on the rows and columns.

Tables can have duplicate rows, but a relation can't have duplicate tuples.

Tables can have duplicate column names, but a relation can't have duplicate attributes.

Yet another difference is that a table isn't very good at displaying the relations DEE and DUM because a table needs at least one column to be visible whereas a relation doesn't need at least one attribute.

Extensions of predicates

Under the Relational Model a relation is used to record the extensions of predicates, i.e. the set of tuples that make the predicate true.

For example the above relation may represent the extension of the following natural language predicate

There exists a supplier under contract identified by supplier number [SNO] with name [SNAME] having status [STATUS] and located in city [CITY]

Operations

The operations on relations give rise to the Relational Algebra