Relational Algebra and Relational Calculus
The most common algebraic query language is called the relational algebra. This language is procedural , in the sense that its expressions actually describe an explicit procedure for returning the results. Languages that use logic fall under the heading of the relational calculus (there is more than one such language in common use). These languages are nonprocedural , since their expressions represent statements that describe conditions that must be met for a row to be in the result table, without showing how to actually obtain those rows. Let us illustrate these ideas with an example.
Consider the following request, written in plain English:
Get the names and phone numbers for publishers who publish books costing under $20.00.
For reference, let us repeat the relevant tables for this request. The BOOKS table appears in Table 5.2, while the PUBLISHERS table is shown in Table 5.3.
Table 5-2. The BOOKS Table from the LIBRARY Database
ISBN |
Title |
PubID |
Price |
---|---|---|---|
0-555-55555-9 |
Macbeth |
2 |
$12.00 |
0-91-335678-7 |
Faerie Queene |
1 |
$15.00 |
0-99-999999-9 |
Emma |
1 |
$20.00 |
0-91-045678-5 |
Hamlet |
2 |
$20.00 |
0-55-123456-9 |
Main Street |
3 |
$22.95 |
1-22-233700-0 |
Visual Basic |
1 |
$25.00 |
0-12-333433-3 |
On Liberty |
1 |
$25.00 |
0-103-45678-9 |
Iliad |
1 |
$25.00 |
1-1111-1111-1 |
C++ |
1 |
$29.95 |
0-321-32132-1 |
Balloon |
3 |
$34.00 |
0-123-45678-0 |
Ulysses |
2 |
$34.00 |
0-99-777777-7 |
King Lear |
2 |
$49.00 |
0-12-345678-9 |
Jane Eyre |
3 |
$49.00 |
0-11-345678-9 |
Moby ... |
Get Access Database Design and Programming, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.