We already discussed about 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 clear examples and concise explanations.
Bookmark this page to have a handy reference for your database queries and SQL optimizations!
Basic Operations
#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. Results in a huge relation. |
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 | Returns tuples from R matching tuples in S based on a condition, without columns from S. |