Chapter 3: Relational Algebra and Relational Calculus
Relational Algebra is more operational and is useful for representing execution plans.
Relational Calculus is non-operational and lets the user describe what they want instead of how to compute it.
Relational Algebra
An algebra is a formal language consisting of sets and their operations.
Operations of relational algebra can be divided into two groups:
- Set operations like UNION, INTERSECTION, SET DIFFERENCE, CROSS PRODUCT.
- Relational database specific operations like SELECT, PROJECT, JOIN.
Set Operations on Relations
- Union Operation: includes all tuples that appear in R1, R2 or both where R1 and R2 are relations.
- For R1 and R2 to be union compatible they should meet the following conditions:
- R1 and R2 must have the same number of attributes.
- Each corresponding pair of attributes must have the same domain.
- Duplicate tuples are automatically eliminated.
- Intersection Operation: includes all tuples that appear in both R1 and R2.
- For R1 and R2 to be intersection compatible they should be union compatible.
- Set Difference: includes all tuples that are an element of R1 but not R2 for R1 - R2.
- For R1 and R2 to be difference compatible they should be union compatible.
- Cartesian Product: includes all tuples that result from the cross product of R1 and R2.
- If R1 has n attributes and R2 has m attributes their cross product will have n * m attributes.
- R1 and R2 don’t have to be union compatible.
Fundamental Operations
To select the attributes subject and author from a Books relation we would use:

To select books where the subject is database and the price is 450 we would use:
