SELECT

The SELECT operation (denoted byσ (sigma)) is used to select a subset of the tuples from a relation based on a selection condition. The selection condition acts as a filterand keeps only those tuples that satisfy the qualifying condition. Tuples satisfying the condition are selected whereas the other tuples are discarded (filtered out)


Database State for COMPANY
Examples:
– Select the EMPLOYEE tuples whose department number is 4:
σ DNO = 4 (EMPLOYEE)
σ Select the employee tuples whose salary is greater than $30,000:
_SALARY > 30,000 (EMPLOYEE)
– In general, the select operation is denoted by σ <selection condition>(R) where
the symbol σ (sigma) is used to denote the select operator
the selection condition is a Boolean (conditional) expression specified
on the attributes of relation R
tuples that make the condition true are selected
(appear in the result of the operation)
tuples that make the condition false are filtered out
(discarded from the result of the operation)
The Boolean expression specified in <selection condition> is made up of a number of clauses of the form:
<attribute name> <comparison op> <constant value>
or
<attribute name> <comparison op> <attribute name>
Where <attribute name> is the name of an attribute of R, <comparison op> id normally
one of the operations {=,>,>=,<,<=,!=}
Clauses can be arbitrarily connected by the Boolean operators and, or and not
For example, To select the tuples for all employees who either work in
department 4 and make over $25000 per year, or work in department 5 and make
over $30000, the select operation should be:
_ (DNO=4 AND Salary>25000 ) OR (DNO=5 AND Salary>30000 ) (EMPLOYEE)

The following query results refer to this database




Examples of applying SELECT and PROJECT operations
SELECT Operation Properties
– SELECT s is commutative:
σ <condition1>(σ < condition2>(R)) = σ <condition2> (σ < condition1> (R))
– A cascade of SELECT operations may be replaced by a
single selection with a conjunction of all the conditions:

σ <cond1>( σ < cond2> (σ <cond3>(R)) = σ <cond1> AND < cond2> AND < cond3>(R)

0 comments