Relational Algebra
The relational algebra is a procedural query language. It consists of a set of operations that take one or two relations and produces a new relation as
their result.
There are a set of operations that are classified as Relational Algebra.
Relational Algebra Operators
operator  binary  type  set type 
project  unary  fundamental  RelationTheoretic 
select  unary  fundamental  RelationTheoretic 
rename  unary  fundamental  RelationTheoretic 
union  binary  fundamental  SetTheoretic 
intersection  binary  additional  SetTheoretic 
difference  binary  fundamental  SetTheoretic 
Cartesian product  binary  fundamental  SetTheoretic 
division  binary  additional  RelationTheoretic 
natural join  binary  additional  RelationTheoretic 
assignment  unary  additional  N/A 
The loan relation
branchname  loannumber  amount 
Downtown  L17  1000 
Redwood  L23  1000 
Perryridge  L15  2000 
Downtown  L14  1500 
Mianus  L93  500 
Round Hill  L11  900 
Perryridge  L16  1300 
LoanSchema = (branchname, loannumber, amount )
The load borrower
customername  loannumber 
Jones  L17 
Smith  L23 
Hayes  L15 
Jackson  L14 
Curry  L93 
Smith  L11 
Williams  L17 
Adams  L16 
Borrowerschema = (customername, loannumber)
The project operator acts as a vertical filter for relations.
Formally, the project operator is defined:
(F(r) = {tt ( r and t satisfies F}.
The project operation is a unary operation that returns its argument relation, with certain attributes left out. For example, if we wish to get a list of the
Loans from the table loan), the relational algebra would be:
(loannumber(loan) )
We get a table that would look like this:
< <
loannumber 
L17 
L23 
L15 
L14 
L93 
L11 
L16 
The select operator acts as a horizontal filter for relations.
The rename operator takes as an input a relation and returns the same relation.
The union of two sets contains all the tuples from each relation.
The intersection of two relations contains all the tuples that are contained in both relations. Can be expressed in terms of the other relations.
The difference between two relations contains all the tuples in the first relation that are not present in the
section relation.
The Cartesian product takes two relations and produces a relation that contains all possible combinations
of the tuples of the first relation combined with each of the tuples of the second relation.
as output, but under a different name.
The natural join operator takes as input two relations and produces as output a relation whose scheme is the concatenation of the two schemes of the input relations with any duplicate attribute names discarded. Can be expressed in terms of the other relations.
The division operator takes as input two relations, called the dividend relation (r on scheme R) and the divisor relation
(s on scheme S such that all the attributes in S also
appear in R and s is not empty. The output of the division
operation is a relation on scheme R with all the attributes common
with S discarded. Can be expressed in terms of the other relations.
The assignment operation works in a manner similar to a programming language
Assignment operator. Can be expressed in terms of the other relations.
CSEE

461

461 S'99

lectures

news

help
Thursday, 18Mar1999 11:40:14 EST