Select

Tuple Level

Syntax:

Written Syntax: σ <conditions>(Relation) Arcade Syntax: Select[cond1 logical-operator cond2](Relation)

Operation Definition

This unary operator returns a subset of the tuples of a relation based on a Boolean condition expression C, which evaluates using the component values of each tuple. This operation requires:

  1. 1) C, an expression that evaluates very similarly to an if statement in C-like languages. It can consist of typical comparison operators such as >, <, != as well as conjunctions such as AND, OR, and NOT. Note that these select statements are typically evaluated at the intra-tuple level. For example, let there be a relation Foo(A, B, C) and we wish to SELECT[A > 4 AND B =’on’](Foo). These comparisons are done row by row, checking each row if the component value of A is greater than 4 and the B is equal to ‘on’.
  2. 2) R – a relation to select from.

Usefulness:

This is often used to select the rows we are interested in. Imagine having a table of orders and you are searching for a specific customers order within a certain date range. A simple well-formed select operation gets you all the information you want, and you can change the values to target different customers and date ranges.

Example: