DBMS – Relational Algebra & Relational Calculus | GATE CSE & Rajasthan Computer Teacher Notes & MCQs

DBMS – Relational Algebra & Relational Calculus

Complete Notes · Operators · Joins · TRC · DRC · Quantifiers · Codd's Theorem · 75 MCQs

GATE CSE · Rajasthan Computer Teacher · UGC NET · ISRO
"Master Relational Algebra & Relational Calculus for GATE CSE and Rajasthan Computer Teacher Exam – Complete Revision Guide"
DBMS, Relational Algebra, Relational Calculus, GATE CSE, Rajasthan Computer Teacher GATE CSE · Rajasthan Computer Teacher · UGC NET · ISRO
Relational Algebra Relational Calculus Joins TRC DRC Codd's Theorem GATE CSE Rajasthan Teacher

Introduction

Database Management Systems (DBMS) is one of the highest-scoring subjects in both GATE CSE and the Rajasthan Computer Teacher Recruitment Examination. Among all DBMS topics, Relational Algebra and Relational Calculus are repeatedly asked in objective as well as conceptual questions.

If you understand these two topics well, you can easily solve SQL-based questions, query processing problems, and theoretical questions. This guide explains every important concept in simple language and provides exam-oriented revision notes.

What is Relational Algebra?

Relational Algebra is a procedural query language used to retrieve data from a relational database.

It tells us how to retrieve the required data by applying a sequence of operations on one or more relations (tables).

Key Features

  • Procedural language
  • Based on set theory
  • Input is one or more relations
  • Output is always a relation
  • Closed under operations
  • Duplicate tuples are removed automatically
💡 Easy Memory Trick: Relational Algebra = HOW to retrieve data

Basic Terminology

Before learning Relational Algebra, remember these basic database terms.

TermMeaning
RelationTable
TupleRow
AttributeColumn
DomainAllowed values of an attribute
DegreeNumber of columns
CardinalityNumber of rows
SchemaStructure of a relation
InstanceCurrent data stored in the table
Primary KeyUnique identifier
Foreign KeyReferences another table's primary key

Basic Operators of Relational Algebra

1. Selection (σ)

Selection retrieves only those rows that satisfy a specified condition.

-- Find employees whose salary is greater than ₹50,000
σ Salary > 50000(Employee)

-- Equivalent SQL
SELECT *
FROM Employee
WHERE Salary > 50000;
💡 Remember: Selection always works on rows.

2. Projection (π)

Projection retrieves only selected columns from a relation.

π Name, Salary(Employee)

-- Equivalent SQL
SELECT Name, Salary
FROM Employee;
💡 Remember: Projection always works on columns.

Selection vs Projection

SelectionProjection
Selects rowsSelects columns
Uses σUses π
Equivalent to WHEREEquivalent to SELECT

3. Union (∪)

Union combines tuples from two compatible relations.

Conditions for Union

  • Same number of columns
  • Same data types
  • Same order of attributes
  • Union compatible schema

Duplicates are removed automatically.

4. Set Difference (−)

Returns tuples present in the first relation but not in the second.

5. Intersection (∩)

Returns only the common tuples present in both relations.

6. Cartesian Product (×)

Produces every possible combination of tuples from two relations.

Formula: Total Rows = m × n

where: m = rows in first table, n = rows in second table

7. Rename Operator (ρ)

Rename changes the name of a relation or attribute.

Join Operations

Join is one of the most important topics in DBMS examinations. A Join combines related tuples from two relations.

Join TypeDescription
Theta Join (θ)Uses comparison operators like <, >, ≤, ≥, =, ≠
Equi JoinUses only equality (=) operator. Duplicate join columns remain.
Natural JoinAutomatically joins based on common attributes. Duplicates removed.
Left Outer JoinAll rows from left table + matching rows from right + NULL
Right Outer JoinAll rows from right table + matching rows from left
Full Outer JoinEvery row from both tables
Self JoinTable joins with itself (e.g., Employee → Manager)

⭐ Important: Natural Join removes duplicate join columns. Equi Join keeps them.

Division Operator (÷)

The Division operator answers "For All" type queries.

  • Students who passed all subjects
  • Employees who know all programming languages

Extended Relational Algebra

Common aggregate functions include:

  • COUNT()
  • SUM()
  • AVG()
  • MIN()
  • MAX()

These are frequently used with GROUP BY and ORDER BY.

Relational Algebra and SQL

Relational AlgebraSQL
Selection (σ)WHERE
Projection (π)SELECT
Union (∪)UNION
Cartesian Product (×)CROSS JOIN
Join (⨝)JOIN
Difference (−)EXCEPT / MINUS

What is Relational Calculus?

Relational Calculus is a non-procedural query language.

Unlike Relational Algebra, it specifies what data is required instead of describing how to retrieve it.

💡 Easy Memory Trick: Relational Calculus = WHAT to retrieve

Tuple Relational Calculus (TRC)

{ t | P(t) }

-- Example: Find employees with salary > 50000
{ t | Employee(t) AND t.salary > 50000 }

Domain Relational Calculus (DRC)

{ <x, y> | P(x, y) }

-- Example
{ <Name, Salary> | Employee(Name, Salary) AND Salary > 50000 }

TRC vs DRC

Tuple Relational CalculusDomain Relational Calculus
Uses tuple variablesUses domain variables
Works on complete rowsWorks on attribute values

Quantifiers

Existential Quantifier (∃)

Meaning: "There exists"

∃x Employee(x)    -- At least one employee exists

Universal Quantifier (∀)

Meaning: "For all"

∀x Employee(x)    -- Used in "for every" type queries
💡 Memory: ∃ → Exists  |  ∀ → All

Safe and Unsafe Expressions

Safe Expression

  • Produces a finite result
  • Can be evaluated

Unsafe Expression

  • Produces an infinite result
  • Cannot be evaluated practically

Codd's Theorem ⭐⭐⭐⭐⭐

Statement: Every query that can be expressed in Relational Algebra can also be expressed in Relational Calculus, and vice versa.

Therefore, both have equal expressive power.

Relational Algebra vs Relational Calculus

Relational AlgebraRelational Calculus
ProceduralNon-Procedural
Specifies HOWSpecifies WHAT
Based on operatorsBased on predicate logic
Practical implementationTheoretical foundation

Frequently Asked Questions in GATE and Rajasthan Computer Teacher Exam

  • Difference between Selection and Projection
  • Difference between Natural Join and Equi Join
  • Join types with examples
  • Union compatibility conditions
  • Cartesian Product formula
  • Division operator applications
  • Difference between Relational Algebra and Relational Calculus
  • TRC vs DRC
  • Safe vs Unsafe Expressions
  • Degree vs Cardinality
  • Primary Key vs Foreign Key
  • Codd's Theorem

Quick Revision Table

Relational AlgebraProcedural (How)
Relational CalculusNon-Procedural (What)
Selection (σ)Rows
Projection (π)Columns
Union (∪)Combine relations
Intersection (∩)Common tuples
Difference (−)Tuples in A but not B
Cartesian Product (×)m × n rows
Natural JoinRemoves duplicate columns
Equi JoinKeeps duplicate columns
Division (÷)For all queries
TRCTuple variables
DRCDomain variables
There exists
For all
DegreeNumber of columns
CardinalityNumber of rows
Codd's TheoremEqual expressive power

Final Exam Tips

  1. Memorize all Relational Algebra symbols and their meanings.
  2. Practice converting SQL queries into Relational Algebra expressions.
  3. Focus on Join operations and Division operator, as they are frequently tested.
  4. Understand the difference between Relational Algebra and Relational Calculus rather than memorizing definitions.
  5. Revise Degree vs Cardinality, Primary Key vs Foreign Key, and Codd's Theorem before the exam.

🎯 Conclusion

"Relational Algebra and Relational Calculus form the theoretical foundation of relational databases and SQL. Mastering these concepts will not only improve your score in GATE CSE and the Rajasthan Computer Teacher Exam, but also strengthen your understanding of DBMS for interviews and software development. Consistent practice with previous-year questions and regular revision of these core concepts will significantly improve your performance in competitive examinations."

Practice MCQs (75 Questions)
सही: 0 गलत: 0 शेष: 75
0 / 75


Loading questions...

परिणाम

0 / 75

बहुत अच्छा!

0 सही
0 गलत
0 अनुत्तरित

ऊपर 'पुनः प्रयास' बटन से दोबारा प्रयास करें

DBMS – Relational Algebra & Relational Calculus • GATE CSE & Rajasthan Computer Teacher • #DBMS #RelationalAlgebra #RelationalCalculus #GATE #RajasthanTeacher