SELECT Statement ()

SELECT (Relational Algebra)

The SELECT operation, , is used to select a subset of tuples from a relation based on a selection condition. The condition acts as a filter and only keeps those tuples that satisfy the qualifying condition.

Where denotes the SELECT operator. Where denotes the relation.

Example:

  • Select the EMPLOYEE tuples whose department number if 4:
  • Select the EMPLOYEE tuples whose salary is greater than £30,000:

Properties:

  • SELECT produces a relation that has the same schema as .
  • SELECT is commutative: .
  • May be applied in any order.
  • We can replace a cascade with a single conjunction.
Link to original

PROJECT Statement ()

PROJECT (Relational Algebra)

The PROJECT operation, , is used to keep certain columns (attributes) from a relation and discard all others. PROJECT uses vertical partitioning, the list of specified columns is kept in each tuple, other attributes in each tuple are discarded. Duplicate rows are removed since relations are sets.

Where denotes the PROJECT operator. Where denotes the desired list of attributes from . Where denotes the relation.

Example:

  • Select the employee’s first name, last name, and salary:

Properties:

  • The number of tuples in the result of a projection is always less or equal to the number of tuples in .
Link to original

RENAME Statement ()

RENAME (Relational Algebra)

The RENAME operation, , is used to rename attributes of a relation or the relation name or both. It is useful when a query requires multiple operations and is necessary in some cases. There are three possible cases:

  • Change relation name to :
  • Change column (attribute) names to :
  • Change combined attribute and relation names:

Example:

  • Apply multiple operations and rename (using ):
Link to original