Database Reference
In-Depth Information
Data request List the names and countries of customers who bought product
5555. Mark the result relation as CUSTPROD5555.
Relational algebra solution
A :
=
SELECT ( SALE : ProductCode
=
'5555' )
B :
JOIN ( CUSTOMER, A )
CUSTPROD5555 :
=
B [ CustomerName, Country ]
Relational calculus solution
CUSTPROD5555
{(r.CustomerName, r.Country) : r IN CUSTOMER and there exists s in SALE
(s.CustomerNo = r.CustomerNo and s.ProductCode = '5555')}
Notice that you need two row variables r and s in the relational calculus
solution. Note also the existence condition. A solution is available only if
qualifying rows exist in relation SALE. The existence condition in a relational
calculus solution is comparable to the JOIN operation in a relational algebra
solution.
=
Procedural and Nonprocedural What is the essential difference you have
noticed between the two languages from the above solution examples? The rela-
tional algebra solution consists of a few steps of distinct operations, whereas the
relational calculus solution is just a single statement. Using relational algebra, you
need to determine the operations and their sequence. With relational calculus, you
just state the result you require. This significant difference expresses the essential
nature of the two generic languages.
Relational Algebra: Procedural Language A procedural language is a language in
which the programmer must code the steps in the proper sequence. The language
allows execution of the distinct steps in the specified sequence. You have to write
the procedure. You have to state how the data manipulation must be done to
produce the solution.
Relational Calculus: Nonprocedural Language When using a nonprocedural lan-
guage, you do not have to specify the steps or operations, nor do you have to state
the order in which the operations must be executed. You do not have to code a pro-
cedure. You do not have to state how the solution must be arrived at. You just have
to state the solution you are looking for. You simply express the solution through
a single solution statement.
Same Solution The generic languages are two different methods for language
implementations. Let us say you arrive at a certain solution relation for a particu-
lar data manipulation request by using an implementation of relational algebra.
According to Dr. Codd, the two languages are relationally equivalent. That means
that you can also arrive at the same solution relation by using an implementation
of relational calculus.
Search WWH ::




Custom Search