Relational Algebra
Most introductory courses on database technology will give an introduction to SQL, a language for both data definition and data manipulation. However, an introduction to relational algebra (RA) is less common. Where SQL is mainly based on predicate logic, the RA provides you with a different view on the concept of a “query”.
Viewing relations as sets of tuples, the RA expresses a query as a combination of operators applied to relations. Some of these operators are the well known set union, intersection and difference. But there are more binary operators, like the join, and also unary operators, like selection and projection. The expressive power of the RA is equivalent to the expressive power of the tuple calculus, which served as a basis for SQL.
The RA has a few nice properties:
- Simplicity. Essentially, the RA is build from only five basic operators.
- Complex queries can be build stepwise, where SQL often requires complex nested logical expressions.
- A query expression in the RA is in some sense a way of defining a result calculation order. In this way, the RA can be used as a tool describing certain aspects of query processing and optimization.
Initially, we will study a pure, set-oriented version of the RA. Later on, we will discuss an extended version of the RA that also deals with duplicates, grouping and aggregates. It will serve as a vehicle for algebraic query optimization for SQL queries.
We offer the following material: