We discussed Relational Algebra in a previous article. But if you’re preparing for an exam or technical interviews, here is a quick reference to efficiently navigate its various operations.
In this cheat sheet, we’ll summarize the most crucial relational algebra operations—including selections, projections, joins, and set operations—with symbols and concise explanations.
Bookmark this page to have a handy reference for your database queries and SQL optimizations.
If you want the longer explanations behind these operators, continue with Relational Algebra, Relational Data Modeling, and Database Normalization.
Basic Operations#
Classical relational algebra uses set semantics: relations contain no duplicate tuples. Projection corresponds to SQL’s SELECT DISTINCT, not generally to SELECT. Outer joins and aggregation belong to extensions of the classical algebra.
| Operation | Symbol | Description |
|---|---|---|
| Selection | σcondition(R) | Selects rows that satisfy a given predicate (like WHERE in SQL). |
| Projection | πattributes(R) | Selects specified columns (removes duplicates). |
| Renaming | ρnew_name(R) | Renames the relation or its attributes. |
Set Operations#
(Relations must be union-compatible – same number and type of attributes.)
| Operation | Symbol | Description |
|---|---|---|
| Union | R ∪ S | Combines tuples from both R and S (removes duplicates). |
| Set Difference | R − S | Tuples in R but not in S. |
| Intersection | R ∩ S | Tuples common to both R and S. (Can be derived as R − (R − S)) |
Cartesian Product (Cross Join)#
| Operation | Symbol | Description |
|---|---|---|
| Cartesian Product | R × S | Combines each tuple of R with every tuple of S. Produces |R| × |S| tuples. |
Joins#
(Used to combine related tuples from different relations.)
| Operation | Symbol | Description |
|---|---|---|
| Theta Join | R ⨝θ S | Combines tuples based on condition θ (e.g., R.A = S.B). |
| Equi Join | R ⨝R.A=S.B S | A theta join using only =. |
| Natural Join | R ⨝ S | Automatically joins on all common attributes. |
| Outer Joins | - | Includes unmatched rows: Left ⟕, Right ⟖, Full ⟗ |
Division (÷)#
| Operation | Symbol | Description |
|---|---|---|
| Division | R ÷ S | Finds tuples in R that are related to all tuples in S. Common in “for all” type queries. |
Other Operations#
| Operation | Symbol | Description |
|---|---|---|
| Assignment | ← | Temporarily assigns the result of expressions to a variable. |
| Aggregate Functions | γfunction(R) | Applies aggregation (COUNT, SUM, AVG, MIN, MAX) on grouped attributes. |
| Semi Join | R ⋉ S or R ⋊ S | R ⋉ S returns matching tuples with only R’s attributes; R ⋊ S returns matching tuples with only S’s attributes. |