Relational Algebra
Relational Query Languages
Query language: language in which a user requests information from the database. They are imperative, functional or declarative. Functional languages use relational algebra, declarative languages use tuple relational calculus as well as domain relational language. These are also known as "pure" languages. They all use the same computing power.
Relational Algebra
A procedural language consisting of a set of operations that take one or two relations as input and produce a new relation as their result.
Operations
Select
The select operation selects tuples that satisfy a given predicate.
Notation:
is called the selection predicate
Result: a subset of tuples with the same attributes of the relation .
We allow comparisons using
Project
A unary operation that returns its argument relation, with certain attributes left out.
Notation: , where are attribute names and is a relation name.
Join (Cartesian-Product)
The Cartesian-Product operation (denoted by X) allows us to combine information from any two relations.
The join operation allows us to combine a select operation and a Cartesian-Product operation into a single operation.
Consider relations and . Let "theta" () be a predicate on attributes in the schema "union" . The join operation is defined as follows:
Union
The union operation allows us to combine two relations. Exactly like the normal union for sets.
Set-Intersection
The set-intersection operation allows us to find tuples that are in both input relations. Exactly like the normal intersection for sets.
Set Difference
The set-difference operation allows us to find tuples that are in one relation but are not in another. Exactly like the difference of sets.
Assignment Operation
It is also possible to assign parts of an expression to temporary relation variables using the
Rename Operation
The results of relational-algebra expressions do not have a name that we can use to refer to them. The rename operator, is used for that purpose.