UMBC CMSC 461 Spring '99 CSEE | 461 | 461 S'99 | lectures | news | Oracle Help | help

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 Relation-Theoretic
select unary fundamental Relation-Theoretic
rename unary fundamental Relation-Theoretic
union binary fundamental Set-Theoretic
intersection binary additional Set-Theoretic
difference binary fundamental Set-Theoretic
Cartesian product binary fundamental Set-Theoretic
division binary additional Relation-Theoretic
natural join binary additional Relation-Theoretic
assignment unary additional N/A

The loan relation
branch-name loan-number amount
Downtown L-17 1000
Redwood L-23 1000
Perryridge L-15 2000
Downtown L-14 1500
Mianus L-93 500
Round Hill L-11 900
Perryridge L-16 1300
Loan-Schema = (branch-name, loan-number, amount )
The load borrower
customer-name loan-number
Jones L-17
Smith L-23
Hayes L-15
Jackson L-14
Curry L-93
Smith L-11
Williams L-17
Adams L-16
Borrower-schema = (customer-name, loan-number)

project

The project operator acts as a vertical filter for relations. Formally, the project operator is defined:
(F(r) = {t|t ( 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:
(loan-number(loan) )


We get a table that would look like this:
< <
loan-number
L-17
L-23
L-15
L-14
L-93
L-11
L-16

select

The select operator acts as a horizontal filter for relations.

rename

The rename operator takes as an input a relation and returns the same relation.

union

The union of two sets contains all the tuples from each relation.

intersection

The intersection of two relations contains all the tuples that are contained in both relations. Can be expressed in terms of the other relations.

difference

The difference between two relations contains all the tuples in the first relation that are not present in the section relation.

Cartesian product

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.

natural join

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.

division

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.

assignment

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, 18-Mar-1999 11:40:14 EST