Selection (relational algebra)

In relational algebra, a selection (sometimes called a restriction in reference to E.F. Codd's 1970 paper[1] and not, on the 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:

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 .

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.

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 SELECT, UPDATE, and 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.

See also

References

This article is issued from Wikipedia - version of the 10/13/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.