Relational Algebra is a step-by-step language for working with relations. You start with one or more relations, apply an operation such as selection, projection, union or join, and get a new relation as the result. In this chapter, every operation is explained in very easy language using the same college database, visual before-and-after tables, memory shortcuts and solved examples so you can understand what each symbol actually does instead of memorising formulas.
What Is Relational Algebra in DBMS?
Relational Algebra is a procedural query language for the relational model. It tells us what operation to apply to one or more relations to produce another relation as the result.
Think of it like a machine. You put a table into the machine, choose an operation, and the machine gives you another table.
Shortcut #1: Input → Operation → Output
Relation + Operation = New RelationThis property is called closure: the result of a relational-algebra operation is again a relation, so you can apply another operation to it.
If relation, tuple, attribute or domain are not fully clear yet, revise Relational Model in DBMS: Relation, Tuple, Attribute & Domain Explained first. Relational Algebra is easier once those four words feel natural.
Our College Database for Every Solved Example
We will keep the same small database in the whole chapter so you do not waste time learning a new example in every section.
STUDENT Relation
| student_id | name | branch | semester |
|---|---|---|---|
| S01 | Asha | CSE | 2 |
| S02 | Ravi | ECE | 2 |
| S03 | Neha | CSE | 1 |
| S04 | Aman | ME | 3 |
COURSE Relation
| course_id | title | credits |
|---|---|---|
| C101 | DBMS | 4 |
| C102 | OS | 4 |
| C103 | Networks | 3 |
ENROLLMENT Relation
| student_id | course_id | grade |
|---|---|---|
| S01 | C101 | A |
| S01 | C102 | B |
| S02 | C101 | B |
| S03 | C101 | A |
Interactive Operation Explorer
Click an operation. Watch what changes between input and output.
| ID | Name | Branch |
|---|---|---|
| S01 | Asha | CSE |
| S02 | Ravi | ECE |
| S03 | Neha | CSE |
| ID | Name | Branch |
|---|---|---|
| S01 | Asha | CSE |
| S03 | Neha | CSE |
Types of Relational Algebra Operations
Different textbooks group operations slightly differently. A useful beginner grouping is:
Basic / Fundamental Operations
Selection, Projection, Union, Set Difference, Cartesian Product and Rename are commonly treated as core operations.
Derived / Common Additional Operations
Intersection, Join and Division can be described using the basic operations, but they are very important in practical learning and exams.
Shortcut #2: S-P-U-D-C-R
Selection · Projection · Union · Difference · Cartesian Product · RenameThen add the high-value derived operations: Intersection, Join and Division.
Selection (σ): Choose Rows
Simple meaning
Selection chooses tuples (rows) that satisfy a condition. It does not choose columns.
σ (sigma)Solved Example 1: Find all CSE students
σ branch = 'CSE' (STUDENT)
| student_id | name | branch | semester |
|---|---|---|---|
| S01 | Asha | CSE | 2 |
| S03 | Neha | CSE | 1 |
Solved Example 2: Find CSE students in semester 2
σ branch = 'CSE' AND semester = 2 (STUDENT)
Only Asha satisfies both conditions.
Shortcut #3: Selection = Select rows
σ → Filter rowsProjection (π): Choose Columns
Simple meaning
Projection chooses attributes (columns) from a relation.
π (pi)Solved Example: Show only student name and branch
π name, branch (STUDENT)
| name | branch |
|---|---|
| Asha | CSE |
| Ravi | ECE |
| Neha | CSE |
| Aman | ME |
Important point: duplicate tuples
In pure relational algebra, relations are sets. If projection produces duplicate tuples, duplicate copies are removed.
Example: projecting only branch from STUDENT gives CSE, ECE and ME. CSE appears for two students in the original relation, but the projected relation contains one CSE tuple.
Shortcut #4: Projection = Pick columns
π → ColumnsSelection = rows. Projection = columns. This is the most important pair to remember.
Selection + Projection Together
Many real questions need both row filtering and column choosing.
Question: Show names of CSE students
π name (σ branch = 'CSE' (STUDENT))
Shortcut #5: Read relational algebra from inside to outside
Just like brackets in mathematics, solve the inner expression first.
Union (∪): Combine Tuples From Two Compatible Relations
Simple meaning
Union gives all tuples that are present in relation A or relation B or both.
∪What does union-compatible mean?
Solved Example
Suppose CSE_STUDENT and ECE_STUDENT both contain only (student_id, name).
CSE_STUDENT ∪ ECE_STUDENT
The result contains all students from both relations, without duplicate tuples.
Shortcut #6: Union = Put both lists together
A ∪ B = in A OR BIntersection (∩): Keep Common Tuples
Simple meaning
Intersection returns tuples that are present in both compatible relations.
∩Solved Example
Let relation A contain students who joined a coding club. Let relation B contain students who joined a robotics club. If both relations have the same structure:
A ∩ B
The result gives students who are members of both clubs.
Shortcut #7: Intersection = AND
A ∩ B = in A AND BSet Difference (−): Keep What Is in A but Not in B
Simple meaning
Set Difference returns tuples that are in the first relation but not in the second.
−A − B is usually different from B − A.Solved Example
A = students registered for DBMS.
B = students who submitted DBMS assignment.
A − B
Result: students registered for DBMS but who have not submitted the assignment.
Shortcut #8: Difference = First list minus second list
A − B = in A but NOT in BCartesian Product (×): Pair Every Tuple With Every Tuple
Simple meaning
Cartesian Product combines every tuple of relation A with every tuple of relation B.
×m × n tuplesMini Example
Relation A
(S01, Asha)
(S02, Ravi)
Relation B
(C101, DBMS)
(C102, OS)
A has 2 tuples and B has 2 tuples. Therefore A × B contains 4 combined tuples.
| student_id | name | course_id | title |
|---|---|---|---|
| S01 | Asha | C101 | DBMS |
| S01 | Asha | C102 | OS |
| S02 | Ravi | C101 | DBMS |
| S02 | Ravi | C102 | OS |
Cartesian Product by itself often creates many meaningless combinations. It becomes very useful as a building block for joins, where a condition removes unwanted combinations.
Shortcut #9: Product = Everybody meets everybody
m rows × n rows = m×n combinationsRename (ρ): Give a Relation or Attribute a New Name
Simple meaning
Rename changes the name of a relation or its attributes for use inside an expression.
ρ (rho)Example
ρ S (STUDENT)
This gives STUDENT the temporary relation name S.
You may also see notation that renames attributes depending on the textbook convention.
Shortcut #10: Rename = Nickname
Think of ρ as giving a relation a short nickname so a complex expression becomes easier to write.
Join: Combine Related Tuples
Simple meaning
A join combines tuples from two relations when they satisfy a relationship condition.
In practical database work, join is one of the most important ideas because related data is usually stored in separate relations.
STUDENT
S01, Asha
S02, Ravi
S03, Neha
ENROLLMENT
S01, C101, A
S02, C101, B
S03, C101, A
Theta Join (θ Join)
A theta join uses a general comparison condition such as =, <, >, ≤, ≥ or ≠.
STUDENT ⋈ STUDENT.student_id = ENROLLMENT.student_id ENROLLMENT
The exact symbol style may differ in notes. The important idea is that a condition decides which combined tuples survive.
Equi Join
An equi join is a theta join whose condition uses equality.
STUDENT.student_id = ENROLLMENT.student_id
Because the matching attributes may appear from both relations, an equi-join result can contain both copies unless projection removes one.
Natural Join (⋈)
A natural join automatically matches attributes with the same name and compatible meaning, and normally keeps one copy of the common join attribute in the result.
Shortcut #11: Join = Product + Matching Condition
Conceptually, you can imagine:
Join ≈ Cartesian Product → Filter matching tuplesSolved Example: Show student names with grades
π name, grade (
STUDENT ⋈ STUDENT.student_id = ENROLLMENT.student_id ENROLLMENT
)
| name | grade |
|---|---|
| Asha | A |
| Asha | B |
| Ravi | B |
| Neha | A |
The first step joins STUDENT with ENROLLMENT using student_id. The projection then keeps only name and grade.
Division (÷): Find “All Of These” Cases
Simple meaning
Division is useful for queries that contain the idea “all.”
÷Suppose ENROLLED(student_id, course_id) contains which student took which course. REQUIRED(course_id) contains the courses every student must complete.
ENROLLED ÷ REQUIRED
The result contains student IDs that are paired with every course present in REQUIRED.
Very small solved example
ENROLLED
S01–C1
S01–C2
S02–C1
REQUIRED
C1
C2
S01 has both C1 and C2. S02 has only C1. Therefore:
ENROLLED ÷ REQUIRED = {S01}
Shortcut #12: Division = “Who has ALL?”
÷ → ALL conditionHow to Solve Division Without Getting Confused
This manual method is perfect for small semester-exam questions.
Complete Solved Example With Selection, Join and Projection
Question
Find the names of CSE students who are enrolled in DBMS (course C101).
Step 1: Select CSE students
CSE = σ branch = 'CSE' (STUDENT)
Step 2: Select DBMS enrollments
DBMS_ENROLL = σ course_id = 'C101' (ENROLLMENT)
Step 3: Join them on student_id
MATCHED =
CSE ⋈ CSE.student_id = DBMS_ENROLL.student_id DBMS_ENROLL
Step 4: Project only name
π name (MATCHED)
Final Answer
| name |
|---|
| Asha |
| Neha |
Shortcut #13: Filter → Connect → Display
Selection → Join → ProjectionThis three-step pattern solves many relational-algebra questions.
Union Compatibility and Other Important Rules
Important Relational Algebra Properties
You do not need advanced proofs for a basic DBMS exam, but a few properties help simplify expressions.
These ideas become useful later when you study query processing and optimization.
Relational Algebra vs SQL
| Relational Algebra | Meaning | Common SQL Connection |
|---|---|---|
| Selection σ | Choose rows | WHERE |
| Projection π | Choose columns | SELECT column_list |
| Union ∪ | Combine compatible results | UNION |
| Difference − | A but not B | EXCEPT / MINUS depending on DBMS |
| Cartesian Product × | Every pair | CROSS JOIN |
| Join ⋈ | Combine related tuples | JOIN ... ON |
| Rename ρ | Temporary naming | Aliases using AS |
SQL and Relational Algebra are not identical languages, but relational algebra gives the theoretical foundation for understanding how relation-oriented queries can be expressed and transformed.
The earlier Integrity Constraints in DBMS chapter explains which relation states are valid. Relational Algebra now explains how we operate on those valid relations.
Do Not Confuse These Operations
How to Write Relational Algebra in Semester Exams
Definition + one operation
Define Relational Algebra in one line and explain the asked operation with symbol and tiny example.
Operation + solved relation
Write meaning, symbol, input table, expression and result table. Selection/projection questions are ideal for this format.
Compare multiple operations
Explain basic operations, set-operation compatibility, joins and one multi-step solved expression. Add division if it is in your syllabus.
For clean answer presentation, use How to Write High-Scoring Answers in University Semester Exams. For unit priority, use the previous-year-paper method.
Practice Questions With Answers
1. What is Relational Algebra?
Relational Algebra is a procedural query language in which operations are applied to one or more relations to produce a new relation.
2. What is the difference between selection and projection?
Selection chooses rows that satisfy a condition. Projection chooses required columns or attributes.
3. Why must relations be union-compatible for union?
Union combines tuples position by position, so the relations need the same number of attributes and compatible corresponding domains.
4. What does Cartesian Product do?
It pairs every tuple of the first relation with every tuple of the second relation. If the relations have m and n tuples, the result has m×n tuples.
5. What is a natural join?
A natural join combines tuples by automatically matching common attribute names with compatible meaning and normally keeps one copy of the common attribute.
6. What is an equi join?
An equi join is a join whose comparison condition uses equality.
7. When is division useful?
Division is useful for “all” queries, such as finding students who completed all required courses.
8. Does projection remove duplicate tuples?
Yes, in pure relational algebra relations use set semantics, so duplicate projected tuples are represented only once.
9. How is join related to Cartesian Product?
A join can be understood conceptually as forming combinations and then keeping only those that satisfy the join condition.
10. What does closure mean in Relational Algebra?
Closure means the result of a relational-algebra operation is again a relation, so another relational-algebra operation can be applied to it.
Relational Algebra One-Minute Revision Sheet
Ultimate memory line
Rows = σ · Columns = π · Combine = ∪/⋈ · All = ÷Frequently Asked Questions
What is Relational Algebra in DBMS in simple words?
Relational Algebra is a way to process relations using operations such as selection, projection and join to produce new relations.
Which are the basic operations of Relational Algebra?
Common fundamental operations include selection, projection, union, set difference, Cartesian product and rename. Intersection, join and division are also important derived or additional operations.
What is the difference between selection and projection?
Selection filters rows using a condition, while projection chooses the required columns.
What is the difference between Cartesian Product and Join?
Cartesian Product creates every possible tuple combination. A join keeps combinations that satisfy a relationship condition.
What is division in Relational Algebra?
Division is used for “all” queries, such as finding students who completed all required courses.
What should I study after Relational Algebra?
Study SQL in detail, relational calculus, functional dependencies and normalization. These topics build directly on relational querying and design.
What Should You Learn After Relational Algebra?
Next: SQL Commands and Query Writing
Relational Algebra gives you the theory of selecting, projecting, combining and joining relations. The next step is to learn how these ideas appear in practical SQL using SELECT, WHERE, JOIN, UNION, GROUP BY, HAVING and subqueries.
After SQL, continue with relational calculus, functional dependencies and normalization. If you want video revision after reading the chapter, use the DBMS YouTube study guide as a secondary resource.
