Selection (relational algebra)
||It has been suggested that Generalized selection be merged into this article. (Discuss) Proposed since February 2016.|
|This article does not cite any sources. (December 2009) (Learn how and when to remove this template message)|
A selection is written as or where:
- and are attribute names
- is a binary operation in the set
- is a value constant
- is a relation
The selection denotes all tuples in for which holds between the and the attribute.
The selection denotes all tuples in for which holds between the attribute and the value .
For an example, consider the following tables where the first table gives the relation , the second table gives the result of and the third table gives the result of .
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.
In computer languages it is expected that any truth-valued expression be permitted as the selection condition rather than restricting it to be a simple comparison.
In SQL, selections are performed by using
WHERE definitions in
DELETE statements, but note that the selection condition can result in any of three truth values (true, false and unknown) instead of the usual two.