Supriya Ghosh (Editor)

Selection (relational algebra)

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

In relational algebra, a selection (sometimes called a restriction in reference to E.F. Codd's 1970 paper 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 σ a θ b ( R ) or σ a θ v ( R ) 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 σ a θ b ( R ) denotes all tuples in R for which θ holds between the a and the b attribute.

    The selection σ a θ v ( R ) 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 P e r s o n , the second table gives the result of σ A g e 34 ( P e r s o n ) and the third table gives the result of σ A g e = W e i g h t ( P e r s o n ) .

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

    σ a θ b ( R ) = {   t : t R ,   t ( a )   θ   t ( b )   } σ a θ v ( R ) = {   t : t R ,   t ( a )   θ   v   }

    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.

    References

    Selection (relational algebra) Wikipedia