Unary Operations

We start the discussion of the relational algebra by examining the two unary operations:
Selection and Projection.
Selection (or Restriction)
spredicate(R) The Selection operation works on a single relation R and defines a
relation that contains only those tuples of R that satisfy the specified
condition ( predicate).
Example 4.1 Selection operation
List all staff with a salary greater than £10,000.
σsalary > 10000(Staff)
Here, the input relation is Staff and the predicate is salary > 10000. The Selection operation
defines a relation containing only those Staff tuples with a salary greater than £10,000. The
result of this operation is shown in Figure 4.2. More complex predicates can be generated
using the logical operators ∧ (AND), ∨ (OR) and ~ (NOT).
Projection
Ða1, . . . , an(R) The Projection operation works on a single relation R and defines a
relation that contains a vertical subset of R, extracting the values of
specified attributes and eliminating duplicates.
Example 4.2 Projection operation
Produce a list of salaries for all staff, showing only the staffNo, fName, lName, and
salary details.
ÐstaffNo, fName, lName, salary(Staff)
In this example, the Projection operation defines a relation that contains only the designated
Staff attributes staffNo, fName, lName, and salary, in the specified order. The result of
this operation is shown in Figure 4.3.

Unary Operations Unary Operations Reviewed by Shopping Sale on 14:18 Rating: 5

No comments:

Powered by Blogger.