How to use the Relational Algebra Calculator
- 1. Define tablesA header like Students(sid, name, city), then one row per line.
- 2. Write an expressionWith symbols like σ and π, or words like select and project.
- 3. EvaluateSee the result table and roughly equivalent SQL.
Supported operations
- σ[condition](R) or select: keep rows that match, such as
σ[city = 'Noida' and sid > 1](Students). - π[columns](R) or project: keep chosen columns and remove duplicate rows.
- R ⋈ S or join: natural join on columns with the same name. R ⋈[condition] S is a theta join.
- R ∪ S, R − S and R ∩ S: union, difference and intersection of compatible relations.
- R × S: Cartesian product.
- ρ[N](R): rename, so a table can be joined with itself.
Conditions support =, <>, <, >, <= and >=, joined with and, or and not. They're read by a small parser, never run as code. Use Table.column when a column name appears in both tables.
Worked example
The sample has Students (4 rows) and Enrolled (5 rows). The question "names and cities of students taking DBMS" is:
π[name, city](σ[course = 'DBMS'](Students ⋈ Enrolled))The natural join matches on sid, giving 5 rows; σ keeps the 2 with course DBMS; π keeps name and city. The result is 2 rows: Asha, Noida and Meera, Noida.
Now try π[sid](Students) − π[sid](Enrolled) to find students not enrolled in anything (none here), or π[sid](σ[course = 'DBMS'](Enrolled)) ∩ π[sid](σ[course = 'Python'](Enrolled)) to find students taking both: just sid 3. The rough SQL translation helps you connect exam-style algebra to the queries you'll write at work.
Frequently asked questions
Why does π remove duplicates?
Relational algebra works on sets, which have no duplicates. SQL keeps duplicates unless you add DISTINCT.
Is division (÷) supported?
Not directly. Write it with − and ×, the standard way to express division in basic operators.
How many rows can my tables have?
Small practice tables of up to a few hundred rows work well.
Is the relational algebra calculator free to use?
Yes, the relational algebra calculator is free and costs nothing. Your first evaluation shows a short form for your name and WhatsApp number one time; once that's done, this tool and every other Uncodemy tool open with no form.