Relational Algebra and Relational Calculus – Comprehensive Notes for GATE and UGC NET
Relational Algebra and Relational Calculus
Your go-to resource for mastering database concepts in GATE and UGC NET exams.
Introduction to Relational Algebra
Relational Algebra is a procedural query language used to retrieve and manipulate data stored in a relational database. It forms the theoretical backbone of SQL and provides a robust framework for query optimization and database design.
Key Operations in Relational Algebra
- Selection (σ): Filters rows based on a specified condition.
- Projection (π): Selects specific columns, eliminating duplicates.
- Union (∪): Combines two relations and removes duplicates.
- Set Difference (−): Returns rows in one relation but not in another.
- Cartesian Product (×): Combines every row of one relation with every row of another.
- Natural Join (⨝): Combines two relations based on common attributes.
- Division (÷): Used for queries involving “all conditions.”
Examples
Selection
Find employees with a salary greater than 50,000.
σ(salary > 50000)(Employee)
Projection
Retrieve the Name and Salary columns of employees.
π(Name, Salary)(Employee)
Join
Combine Employee and Department based on department ID.
Employee ⨝ (Employee.dept_id = Department.dept_id) Department
Relational Calculus
Relational Calculus is a declarative query language. It emphasizes what data to retrieve without specifying how to retrieve it. There are two forms:
- Tuple Relational Calculus (TRC): Works with tuples.
- Domain Relational Calculus (DRC): Works with domains of attributes.
GATE and UGC NET Focus
Both Relational Algebra and Relational Calculus are crucial topics for database-related questions in GATE and UGC NET exams. Example questions often involve forming queries using algebraic operations or evaluating their results.
Sample GATE Question
Question: Find students scoring above 75 marks using Relational Algebra.
σ(marks > 75)(Student)