Synonyms

Selection (Relational Algebra)

Definition

Given a relation instance R over set of attributes U and a condition F, the selection σ F (R) returns a new relation over U consisting of the set of tuples of R which satisfy F. The condition F is an atom of the form A = B or A = c, where A and B are attributes in U and c is a constant value.

The generalized selection allows more complex conditions: F can be an arbitrary Boolean combination of atoms of the form A = B or A ≠ B or A = c or A ≠ c. Moreover, if a total order is defined on the domain of attributes, more general comparison atoms of the form A α B or A α c are allowed, where α ranges over {=, ≠, <, >, ≤, ≥}.

Key Points

The selection is one of the basic operators of the relational algebra. It operates by “selecting” rows of the input relation. A tuple t over U satisfies the condition A = B if the values of attributes A and B in t are equal. Similarly t satisfies the condition A = c if the value of attribute A in t is c. Satisfaction of generalized selection atoms is defined analogously.

As an example, consider a relation Exams over attributes (course-number, student-number, grade), containing tuples {(EH1, 1001, A), (EH1, 1002, A), (GH5, 1001, C)}. Then σ grade=Acoursenumber = EH1(Exams) is a relation over attributes (course-number, student-number, grade) with tuples {(EH1, 1001, A), (EH1, 1002, A)}.

In the case that a relation schema is only specified by a relation name and arity, the result of the selection is a new relation having the same arity as the input one, containing the tuples which satisfy the selection condition. In this case the selection atoms are expressions of the form j = k or j = c (or j α k and j α c in the generalized selection). Here j and k are positive integers bounded by the arity of the input relation, identifying its j-th and k-th attributes, respectively.

Cross-References