In database theory, relational algebra is a theory that uses algebraic structures for modeling data, and defining queries on it with well founded semantics. The theory was introduced by Edgar F. Codd.
The main application of relational algebra is to provide a theoretical foundation for relational databases, particularly query languages for such databases, chief among which is SQL. Relational databases store tabular data represented as relations. Queries over relational databases often likewise return tabular data represented as relations.
The main purpose of relational algebra is to define operators that transform one or more input relations to an output relation. Given that these operators accept relations as input and produce relations as output, they can be combined and used to express complex queries that transform multiple input relations (whose data are stored in the database) into a single output relation (the query results).
Unary operators accept a single relation as input. Examples include operators to filter certain attributes (columns) or tuples (rows) from an input relation. Binary operators accept two relations as input and combine them into a single output relation. For example, taking all tuples found in either relation (union), removing tuples from the first relation found in the second relation (difference), extending the tuples of the first relation with tuples in the second relation matching certain conditions, and so forth.
Other more advanced operators can also be included, where the inclusion or exclusion of certain operators gives rise to a family of algebras.
Relational algebra received little attention outside of pure mathematics until the publication of E.F. Codd's relational model of data in 1970. Codd proposed such an algebra as a basis for database query languages. (See section Implementations.)
Relational algebra operates on homogeneous sets of tuples
S=\{(sj1,sj2,...sjn)|j\in1...m\}
The relational algebra uses set union, set difference, and Cartesian product from set theory, but adds additional constraints to these operators.
For set union and set difference, the two relations involved must be union-compatible—that is, the two relations must have the same set of attributes. Because set intersection is defined in terms of set union and set difference, the two relations involved in set intersection must also be union-compatible.
For the Cartesian product to be defined, the two relations involved must have disjoint headers—that is, they must not have a common attribute name.
In addition, the Cartesian product is defined differently from the one in set theory in the sense that tuples are considered to be "shallow" for the purposes of the operation. That is, the Cartesian product of a set of n-tuples with a set of m-tuples yields a set of "flattened" -tuples (whereas basic set theory would have prescribed a set of 2-tuples, each containing an n-tuple and an m-tuple). More formally, R × S is defined as follows:
The cardinality of the Cartesian product is the product of the cardinalities of its factors, that is, |R × S| = |R| × |S|.
See main article: Projection (relational algebra). A projection is a unary operation written as
\Pi | |
a1,\ldots,an |
(R)
a1,\ldots,an
\{a1,\ldots,an\}
Note: when implemented in SQL standard the "default projection" returns a multiset instead of a set, and the projection to eliminate duplicate data is obtained by the addition of the DISTINCT
keyword.
See main article: Selection (relational algebra). A generalized selection is a unary operation written as
\sigma\varphi(R)
To obtain a listing of all friends or business associates in an address book, the selection might be written as
\sigmaisFriend=true(addressBook)
See main article: Rename (relational algebra). A rename is a unary operation written as
\rhoa(R)
To rename the "isFriend" attribute to "isBusinessContact" in a relation,
\rhoisBusinessContact/isFriend(addressBook)
There is also the
\rho | |
x(A1,\ldots,An) |
(R)
\{a1,\ldots,an\}
\{A1,\ldots,An\}
Natural join (⨝) is a binary operator that is written as (R ⨝ S) where R and S are relations. The result of the natural join is the set of all combinations of tuples in R and S that are equal on their common attribute names. For an example consider the tables Employee and Dept and their natural join:
- ! Name | EmpId | DeptName | - | Harry | 3415 | Finance | - | Sally | 2241 | Sales | - | George | 3401 | Finance | - | Harriet | 2202 | Sales | - | Mary | 1257 | Human Resources |
---|
- ! DeptName | Manager | - | Finance | George | - | Sales | Harriet | - | Production | Charles |
---|
- ! Name | EmpId | DeptName | Manager | - | Harry | 3415 | Finance | George | - | Sally | 2241 | Sales | Harriet | - | George | 3401 | Finance | George | - | Harriet | 2202 | Sales | Harriet |
---|
Note that neither the employee named Mary nor the Production department appear in the result.
This can also be used to define composition of relations. For example, the composition of Employee and Dept is their join as shown above, projected on all but the common attribute DeptName. In category theory, the join is precisely the fiber product.
The natural join is arguably one of the most important operators since it is the relational counterpart of the logical AND operator. Note that if the same variable appears in each of two predicates that are connected by AND, then that variable stands for the same thing and both appearances must always be substituted by the same value (this is a consequence of the idempotence of the logical AND). In particular, natural join allows the combination of relations that are associated by a foreign key. For example, in the above example a foreign key probably holds from Employee.DeptName to Dept.DeptName and then the natural join of Employee and Dept combines all employees with their departments. This works because the foreign key holds between attributes with the same name. If this is not the case such as in the foreign key from Dept.Manager to Employee.Name then these columns must be renamed before taking the natural join. Such a join is sometimes also referred to as an equijoin (see θ-join).
More formally the semantics of the natural join are defined as follows:
where Fun(t) is a predicate that is true for a relation t (in the mathematical sense) iff t is a function (that is, t does not map any attribute to multiple values). It is usually required that R and S must have at least one common attribute, but if this constraint is omitted, and R and S have no common attributes, then the natural join becomes exactly the Cartesian product.
The natural join can be simulated with Codd's primitives as follows. Assume that c1,...,cm are the attribute names common to R and S, r1,...,rn are theattribute names unique to R and s1,...,sk are theattribute names unique to S. Furthermore, assume that the attribute names x1,...,xm are neither in R nor in S. In a first step the common attribute names in S can be renamed:
Then we take the Cartesian product and select the tuples that are to be joined:
Finally we take a projection to get rid of the renamed attributes:
Consider tables Car and Boat which list models of cars and boats and their respective prices. Suppose a customer wants to buy a car and a boat, but she does not want to spend more money for the boat than for the car. The θ-join (⋈θ) on the predicate CarPrice ≥ BoatPrice produces the flattened pairs of rows which satisfy the predicate. When using a condition where the attributes are equal, for example Price, then the condition may be specified as Price=Priceor alternatively (Price) itself.
- ! CarModel | CarPrice | - | CarA | 20,000 | - | CarB | 30,000 | - | CarC | 50,000 |
---|
- ! BoatModel | BoatPrice | - | Boat1 | 10,000 | - | Boat2 | 40,000 | - | Boat3 | 60,000 |
---|
- ! CarModel | CarPrice | BoatModel | BoatPrice | - | CarA | 20,000 | Boat1 | 10,000 | - | CarB | 30,000 | Boat1 | 10,000 | - | CarC | 50,000 | Boat1 | 10,000 | - | CarC | 50,000 | Boat2 | 40,000 |
---|
In order to combine tuples from two relations where the combination condition is not simply the equality of shared attributes it is convenient to have a more general form of join operator, which is the θ-join (or theta-join). The θ-join is a binary operator that is written as
{R \bowtie S\atopa \theta b}
{R \bowtie S\atopa \theta v}
The simulation of this operation in the fundamental operations is therefore as follows:
R ⋈θ S = σθ(R × S)
In case the operator θ is the equality operator (=) then this join is also called an equijoin.
Note, however, that a computer language that supports the natural join and selection operators does not need θ-join as well, as this can be achieved by selection from the result of a natural join (which degenerates to Cartesian product when there are no shared attributes).
In SQL implementations, joining on a predicate is usually called an inner join, and the on keyword allows one to specify the predicate used to filter the rows. It is important to note: forming the flattened Cartesian product then filtering the rows is conceptually correct, but an implementation would use more sophisticated data structures to speed up the join query.
The left semijoin is a joining similar to the natural join and written as where and are relations. The result is the set of all tuples in for which there is a tuple in that is equal on their common attribute names. The difference from a natural join is that other columns of do not appear. For example, consider the tables Employee and Dept and their semijoin:
- ! Name | EmpId | DeptName | - | Harry | 3415 | Finance | - | Sally | 2241 | Sales | - | George | 3401 | Finance | - | Harriet | 2202 | Production |
---|
- ! DeptName | Manager | - | Sales | Sally | - | Production | Harriet |
---|
- ! Name | EmpId | DeptName | - | Sally | 2241 | Sales | - | Harriet | 2202 | Production |
---|
More formally the semantics of the semijoin can be defined asfollows:
where is as in the definition of natural join.
The semijoin can be simulated using the natural join as follows. If are the attribute names of , then
Since we can simulate the natural join with the basic operators it follows that this also holds for the semijoin.
In Codd's 1970 paper, semijoin is called restriction.[2]
The antijoin, written as R ▷ S where R and S are relations, is similar to the semijoin, but the result of an antijoin is only those tuples in R for which there is no tuple in S that is equal on their common attribute names.
For an example consider the tables Employee and Dept and theirantijoin:
- ! Name | EmpId | DeptName | - | Harry | 3415 | Finance | - | Sally | 2241 | Sales | - | George | 3401 | Finance | - | Harriet | 2202 | Production |
---|
- ! DeptName | Manager | - | Sales | Sally | - | Production | Harriet |
---|
- ! Name | EmpId | DeptName | - | Harry | 3415 | Finance | - | George | 3401 | Finance |
---|
The antijoin is formally defined as follows:
or
where is as in the definition of natural join.
The antijoin can also be defined as the complement of the semijoin, as follows:Given this, the antijoin is sometimes called the anti-semijoin, and the antijoin operator is sometimes written as semijoin symbol with a bar above it, instead of ▷.
In the case where the relations have the same attributes (union-compatible), antijoin is the same as minus.
- ! Student | Task | - | Fred | Database1 | - | Fred | Database2 | - | Fred | Compiler1 | - | Eugene | Database1 | - | Eugene | Compiler1 | - | Sarah | Database1 | - | Sarah | Database2 |
---|
- ! Task | - | Database1 | - | Database2 |
- ! Student | - | Fred | - | Sarah |
More formally the semantics of the division is defined as follows:where is the set of attribute names unique to R and t[''a''<sub>1</sub>,...,''a''<sub>''n''</sub>] is the restriction of t to this set. It is usually required that the attribute names in the header of S are a subset of those of R because otherwise the result of the operation will always be empty.
The simulation of the division with the basic operations is as follows. We assume that a1,...,an are the attribute names unique to R and b1,...,bm are the attribute names of S. In the first step we project R on its unique attribute names and construct all combinations with tuples in S:
T := πa1,...,an(R) × S
In the prior example, T would represent a table such that every Student (because Student is the unique key / attribute of the Completed table) is combined with every given Task. So Eugene, for instance, would have two rows, Eugene → Database1 and Eugene → Database2 in T.
EG: First, let's pretend that "Completed" has a third attribute called "grade". It's unwanted baggage here, so we must project it off always. In fact in this step we can drop "Task" from R as well; the multiply puts it back on.
T := πStudent(R) × S // This gives us every possible desired combination, including those that don't actually exist in R, and excluding others (eg Fred | compiler1, which is not a desired combination)
- ! Student | Task | - | Fred | Database1 | - | Fred | Database2 | - | Eugene | Database1 | - | Eugene | Database2 | - | Sarah | Database1 | - | Sarah | Database2 |
---|
U := T - RIn U we have the possiblecombinations that "could have" been in R, but weren't.
EG: Again with projections — T and R need to have identical attribute names/headers.
U := T - πStudent,Task(R) // This gives us a "what's missing" list.
- ! Student | Task | - | Fred | Database1 | - | Fred | Database2 | - | Eugene | Database1 | - | Eugene | Database2 | - | Sarah | Database1 | - | Sarah | Database2 |
---|
- ! Student | Task | - | Fred | Database1 | - | Fred | Database2 | - | Fred | Compiler1 | - | Eugene | Database1 | - | Eugene | Compiler1 | - | Sarah | Database1 | - | Sarah | Database2 |
---|
+ T - R | + aka | + what's missing | - ! Student | Task | - | Eugene | Database2 |
---|
V := πa1,...,an(U)
EG: Project U down to just the attribute(s) in question (Student)
V := πStudent(U)
- ! Student | - | Eugene |
So what remains to be done is take the projection of R on itsunique attribute names and subtract those in V:
W := πa1,...,an(R) - V
EG: W := πStudent(R) - V.
- ! Student | - | Fred | - | Eugene | - | Sarah |
- ! Student | - | Eugene |
+ | + aka | + desired result | - ! Student | - | Fred | - | Sarah |
In practice the classical relational algebra described above is extended with various operations such as outer joins, aggregate functions and even transitive closure.[3]
Whereas the result of a join (or inner join) consists of tuples formed by combining matching tuples in the two operands, an outer join contains those tuples and additionally some tuples formed by extending an unmatched tuple in one of the operands by "fill" values for each of the attributes of the other operand. Outer joins are not considered part of the classical relational algebra discussed so far.[4]
The operators defined in this section assume the existence of a null value, ω, which we do not define, to be used for the fill values; in practice this corresponds to the NULL in SQL. In order to make subsequent selection operations on the resulting table meaningful, a semantic meaning needs to be assigned to nulls; in Codd's approach the propositional logic used by the selection is extended to a three-valued logic, although we elide those details in this article.
Three outer join operators are defined: left outer join, right outer join, and full outer join. (The word "outer" is sometimes omitted.)
The left outer join is written as R ⟕ S where R and S are relations. The result of the left outer join is the set of all combinations of tuples in R and S that are equal on their common attribute names, in addition (loosely speaking) to tuples in R that have no matching tuples in S.
For an example consider the tables Employee and Dept and their left outer join:
- ! Name | EmpId | DeptName | - | Harry | 3415 | Finance | - | Sally | 2241 | Sales | - | George | 3401 | Finance | - | Harriet | 2202 | Sales | - | Tim | 1123 | Executive |
---|
- ! DeptName | Manager | - | Sales | Harriet | - | Production | Charles |
---|
- ! Name | EmpId | DeptName | Manager | - | Harry | 3415 | Finance | ω | - | Sally | 2241 | Sales | Harriet | - | George | 3401 | Finance | ω | - | Harriet | 2202 | Sales | Harriet | - | Tim | 1123 | Executive | ω |
---|
In the resulting relation, tuples in S which have no common values in common attribute names with tuples in R take a null value, ω.
Since there are no tuples in Dept with a DeptName of Finance or Executive, ωs occur in the resulting relation where tuples in Employee have a DeptName of Finance or Executive.
Let r1, r2, ..., rn be the attributes of the relation R and let be the singletonrelation on the attributes that are unique to the relation S (those that are not attributes of R). Then the left outer join can be described in terms of the natural join (and hence using basic operators) as follows:
(R\bowtieS)\cup((R-
\pi | |
r1,r2,...,rn |
(R\bowtieS)) x \{(\omega,...,\omega)\})
The right outer join of relations R and S is written as R ⟖ S. The result of the right outer join is the set of all combinations of tuples in R and S that are equal on their common attribute names, in addition to tuples in S that have no matching tuples in R.
For example, consider the tables Employee and Dept and theirright outer join:
- ! Name | EmpId | DeptName | - | Harry | 3415 | Finance | - | Sally | 2241 | Sales | - | George | 3401 | Finance | - | Harriet | 2202 | Sales | - | Tim | 1123 | Executive |
---|
- ! DeptName | Manager | - | Sales | Harriet | - | Production | Charles |
---|
- ! Name | EmpId | DeptName | Manager | - | Sally | 2241 | Sales | Harriet | - | Harriet | 2202 | Sales | Harriet | - | ω | ω | Production | Charles |
---|
In the resulting relation, tuples in R which have no common values in common attribute names with tuples in S take a null value, ω.
Since there are no tuples in Employee with a DeptName of Production, ωs occur in the Name and EmpId attributes of the resulting relation where tuples in Dept had DeptName of Production.
Let s1, s2, ..., sn be the attributes of the relation S and let be the singletonrelation on the attributes that are unique to the relation R (those that are not attributes of S). Then, as with the left outer join, the right outer join can be simulated using the natural join as follows:
(R\bowtieS)\cup(\{(\omega,...,\omega)\} x (S-
\pi | |
s1,s2,...,sn |
(R\bowtieS)))
The outer join or full outer join in effect combines the results of the left and right outer joins.
The full outer join is written as R ⟗ S where R and S are relations. The result of the full outer join is the set of all combinations of tuples in R and S that are equal on their common attribute names, in addition to tuples in S that have no matching tuples in R and tuples in R that have no matching tuples in S in their common attribute names.
For an example consider the tables Employee and Dept and theirfull outer join:
- ! Name | EmpId | DeptName | - | Harry | 3415 | Finance | - | Sally | 2241 | Sales | - | George | 3401 | Finance | - | Harriet | 2202 | Sales | - | Tim | 1123 | Executive |
---|
- ! DeptName | Manager | - | Sales | Harriet | - | Production | Charles |
---|
- ! Name | EmpId | DeptName | Manager | - | Harry | 3415 | Finance | ω | - | Sally | 2241 | Sales | Harriet | - | George | 3401 | Finance | ω | - | Harriet | 2202 | Sales | Harriet | - | Tim | 1123 | Executive | ω | - | ω | ω | Production | Charles |
---|
In the resulting relation, tuples in R which have no common values in common attribute names with tuples in S take a null value, ω. Tuples in S which have no common values in common attribute names with tuples in R also take a null value, ω.
The full outer join can be simulated using the left and right outer joins (and hence the natural join and set union) as follows:
R ⟗ S = (R ⟕ S) ∪ (R ⟖ S)
There is nothing in relational algebra introduced so far that would allow computations on the data domains (other than evaluation of propositional expressions involving equality). For example, it is not possible using only the algebra introduced so far to write an expression that would multiply the numbers from two columns, e.g. a unit price with a quantity to obtain a total price. Practical query languages have such facilities, e.g. the SQL SELECT allows arithmetic operations to define new columns in the result EXTEND
keyword.[5] In database theory, this is called extended projection.
Furthermore, computing various functions on a column, like the summing up of its elements, is also not possible using the relational algebra introduced so far. There are five aggregate functions that are included with most relational database systems. These operations are Sum, Count, Average, Maximum and Minimum. In relational algebra the aggregation operation over a schema (A1, A2, ... An) is written as follows:
G1,G2,\ldots,Gm g
f1({A1 |
'),f2({A2}'),\ldots,fk({Ak}')} (r)
where each Aj', 1 ≤ j ≤ k, is one of the original attributes Ai, 1 ≤ i ≤ n.
The attributes preceding the g are grouping attributes, which function like a "group by" clause in SQL. Then there are an arbitrary number of aggregation functions applied to individual attributes. The operation is applied to an arbitrary relation r. The grouping attributes are optional, and if they are not supplied, the aggregation functions are applied across the entire relation to which the operation is applied.
Let's assume that we have a table named with three columns, namely and . We wish to find the maximum balance of each branch. This is accomplished by GMax. To find the highest balance of all accounts regardless of branch, we could simply write GMax.
Grouping is often written as ɣMax instead.
Although relational algebra seems powerful enough for most practical purposes, there are some simple and natural operators on relations that cannot be expressed by relational algebra. One of them is the transitive closure of a binary relation. Given a domain D, let binary relation R be a subset of D×D. The transitive closure R+ of R is the smallest subset of D×D that contains R and satisfies the following condition:
\forallx\forally\forallz\left((x,y)\inR+\wedge(y,z)\inR+ ⇒ (x,z)\inR+\right)
It can be proved using the fact that there is no relational algebra expression E(R) taking R as a variable argument that produces R+.[6]
SQL however officially supports such fixpoint queries since 1999, and it had vendor-specific extensions in this direction well before that.
Relational database management systems often include a query optimizer which attempts to determine the most efficient way to execute a given query. Query optimizers enumerate possible query plans, estimate their cost, and pick the plan with the lowest estimated cost. If queries are represented by operators from relational algebra, the query optimizer can enumerate possible query plans by rewriting the initial query using the algebraic properties of these operators.
Queries can be represented as a tree, where
The primary goal of the query optimizer is to transform expression trees into equivalent expression trees, where the average size of the relations yielded by subexpressions in the tree is smaller than it was before the optimization. The secondary goal is to try to form common subexpressions within a single query, or if there is more than one query being evaluated at the same time, in all of those queries. The rationale behind the second goal is that it is enough to compute common subexpressions once, and the results can be used in all queries that contain that subexpression.
Here are a set of rules that can be used in such transformations.
Rules about selection operators play the most important role in query optimization. Selection is an operator that very effectively decreases the number of rows in its operand, so if the selections in an expression tree are moved towards the leaves, the internal relations (yielded by subexpressions) will likely shrink.
Selection is idempotent (multiple applications of the same selection have no additional effect beyond the first one), and commutative (the order selections are applied in has no effect on the eventual result).
\sigmaA(R)=\sigmaA\sigmaA(R)
\sigmaA\sigmaB(R)=\sigmaB\sigmaA(R)
A selection whose condition is a conjunction of simpler conditions is equivalent to a sequence of selections with those same individual conditions, and selection whose condition is a disjunction is equivalent to a union of selections. These identities can be used to merge selections so that fewer selections need to be evaluated, or to split them so that the component selections may be moved or optimized separately.
\sigmaA(R)=\sigmaA(\sigmaB(R))=\sigmaB(\sigmaA(R))
\sigmaA(R)=\sigmaA(R)\cup\sigmaB(R)
Cross product is the costliest operator to evaluate. If the input relations have N and M rows, the result will contain
NM
This can be effectively done if the cross product is followed by a selection operator, e.g.
\sigmaA(R x P)
In the above case the condition A is broken up in to conditions B, C and D using the split rules about complex selection conditions, so that
A=B\wedgeC\wedgeD
\sigmaA(R x P)=\sigmaB(R x P)=\sigmaD(\sigmaB(R) x \sigmaC(P))
Selection is distributive over the set difference, intersection, and union operators. The following three rules are used to push selection below set operations in the expression tree. For the set difference and the intersection operators, it is possible to apply the selection operator to just one of the operands following the transformation. This can be beneficial where one of the operands is small, and the overhead of evaluating the selection operator outweighs the benefits of using a smaller relation as an operand.
\sigmaA(R\setminusP)=\sigmaA(R)\setminus\sigmaA(P)=\sigmaA(R)\setminusP
\sigmaA(R\cupP)=\sigmaA(R)\cup\sigmaA(P)
\sigmaA(R\capP)=\sigmaA(R)\cap\sigmaA(P)=\sigmaA(R)\capP=R\cap\sigmaA(P)
Selection commutes with projection if and only if the fields referenced in the selection condition are a subset of the fields in the projection. Performing selection before projection may be useful if the operand is a cross product or join. In other cases, if the selection condition is relatively expensive to compute, moving selection outside the projection may reduce the number of tuples which must be tested (since projection may produce fewer tuples due to the elimination of duplicates resulting from omitted fields).
\pi | |
a1,\ldots,an |
(\sigmaA(R))=\sigmaA(\pi
a1,\ldots,an |
(R))wherefieldsinA\subseteq\{a1,\ldots,an\}
Projection is idempotent, so that a series of (valid) projections is equivalent to the outermost projection.
\pi | |
a1,\ldots,an |
(\pi | |
b1,\ldots,bm |
(R))=
\pi | |
a1,\ldots,an |
(R)where\{a1,\ldots,an\}\subseteq\{b1,\ldots,bm\}
Projection is distributive over set union.
\pi | |
a1,\ldots,an |
(R\cupP)=
\pi | |
a1,\ldots,an |
(R)\cup
\pi | |
a1,\ldots,an |
(P).
Projection does not distribute over intersection and set difference. Counterexamples are given by:
\piA(\{\langleA=a,B=b\rangle\}\cap\{\langleA=a,B=b'\rangle\})=\emptyset
\piA(\{\langleA=a,B=b\rangle\})\cap\piA(\{\langleA=a,B=b'\rangle\})=\{\langleA=a\rangle\}
and
\piA(\{\langleA=a,B=b\rangle\}\setminus\{\langleA=a,B=b'\rangle\})=\{\langleA=a\rangle\}
\piA(\{\langleA=a,B=b\rangle\})\setminus\piA(\{\langleA=a,B=b'\rangle\})=\emptyset,
Successive renames of a variable can be collapsed into a single rename. Rename operations which have no variables in common can be arbitrarily reordered with respect to one another, which can be exploited to make successive renames adjacent so that they can be collapsed.
\rhoa(\rhob(R))=\rhoa(R)
\rhoa(\rhoc(R))=\rhoc(\rhoa(R))
Rename is distributive over set difference, union, and intersection.
\rhoa(R\setminusP)=\rhoa(R)\setminus\rhoa(P)
\rhoa(R\cupP)=\rhoa(R)\cup\rhoa(P)
\rhoa(R\capP)=\rhoa(R)\cap\rhoa(P)
Cartesian product is distributive over union.
(A x B)\cup(A x C)=A x (B\cupC)
The first query language to be based on Codd's algebra was Alpha, developed by Dr. Codd himself. Subsequently, ISBL was created, and this pioneering work has been acclaimed by many authorities[7] as having shown the way to make Codd's idea into a useful language. Business System 12 was a short-lived industry-strength relational DBMS that followed the ISBL example.
In 1998 Chris Date and Hugh Darwen proposed a language called Tutorial D intended for use in teaching relational database theory, and its query language also draws on ISBL's ideas.[8] Rel is an implementation of Tutorial D. Bmg is an implementation of relational algebra in Ruby which closely follows the principles of Tutorial D and The Third Manifesto.[9]
Even the query language of SQL is loosely based on a relational algebra, though the operands in SQL (tables) are not exactly relations and several useful theorems about the relational algebra do not hold in the SQL counterpart (arguably to the detriment of optimisers and/or users). The SQL table model is a bag (multiset), rather than a set. For example, the expression
(R\cupS)\setminusT=(R\setminusT)\cup(S\setminusT)
Practically any academic textbook on databases has a detailed treatment of the classic relational algebra.