Mastering Relational Algebra for Database Queries
Classified in Computers
Written on in
English with a size of 4.53 KB
Relational Algebra Fundamentals
- Relational Algebra is a mathematical query language used in databases.
- The result of any operation is always another relation (table).
Relational Algebra Operations Explained
Unary Relational Operations
SELECT (σ) – Filters Rows
- Retrieves specific rows from a table based on a condition.
- Syntax:
σ (condition) (Relation) - Example:
σ (Dept_ID = 4) (EMPLOYEE)
PROJECT (π) – Filters Columns
- Retrieves specific columns from a table.
- Syntax:
π (column1, column2) (Relation) - Example:
π (Name, Salary) (EMPLOYEE)
RENAME (ρ) – Changes Table or Column Name
- Syntax:
ρ (NewTable (NewColumn1, NewColumn2), OldTable) - Example:
ρ (Staff (Emp_ID, FullName), EMPLOYEE)
Set Theory Operations
UNION (∪) – Combines Two Tables
- Combines tuples