Selection (relational algebra)

Mutation and Selection

In relational algebra, a selection (sometimes called a restriction in reference to E.F. Codd's 1970 paper[1] and not, contrary to a popular belief, to avoid confusion with SQL's use of SELECT, since Codd's article predates the existence of SQL) is a unary operation that denotes a subset of a relation.

A selection is written as or where:

  • a and b are attribute names
  • θ is a binary operation in the set
  • v is a value constant
  • R is a relation

The selection denotes all tuples in R for which θ holds between the a and the b attribute.

The selection denotes all tuples in R for which θ holds between the a attribute and the value v.

For an example, consider the following tables where the first table gives the relation Person, the second table gives the result of and the third table gives the result of .

Name Age Weight
Harry 34 80
Sally 28 64
George 29 70
Helena 54 54
Peter 34 80
Name Age Weight
Harry 34 80
Helena 54 54
Peter 34 80
Name Age Weight
Helena 54 54

More formally the semantics of the selection is defined as follows:

The result of the selection is only defined if the attribute names that it mentions are in the heading of the relation that it operates upon.

  1. ^ Codd, E.F. (June 1970). "A Relational Model of Data for Large Shared Data Banks". Communications of the ACM. 13 (6): 377–387. doi:10.1145/362384.362685.