Lukas' Notes

relational-algebra

Definition

Division (Relational Algebra)

Let and be relations, where ‘s attributes are a subset of ‘s. The division is the largest relation over whose Cartesian product with is contained in :

Concretely, is in exactly when it is paired in with every tuple of . Division answers “for all” queries against the data.

Construction from Primitive Operators

Division is not primitive: it can be expressed using projection, difference, and the Cartesian product. Denoting the schema of minus the schema of as ,

The expression has four stages:

  1. — the candidate set: every -tuple that appears in , with the -attributes dropped.
  2. — every candidate paired with every tuple of .
  3. — the missing pairs: candidate– combinations that do not occur in . A candidate appearing here fails the “for all” requirement for at least one -tuple.
  4. — subtract from the candidates those proven to be missing a required combination.

The candidates that survive are exactly those whose Cartesian product with is contained in .

Candidate is dropped because the required pair is absent from ; candidate survives because both and occur.