Relational Algebra
Introduction
Relational algebra is a procedural query language used to query and manipulate data in relational databases.
It provides a foundation for SQL, and defines operations on relations (or tables) to produce new relations.
The key features are:
- Operates on one or more relations.
- Outputs a new relation.
- Uses a mathematical approach.
It is very important because it:
- Forms the theoretical foundation of relational databases.
- Helps in query optimization.
- Translates user-friendly SQL queries into executable instructions.
- Promotes a deeper understanding of database operations.
Query Processing
Query processing steps include:
- Parsing and translation
- Optimization
- Evaluation
Basic Relational Algebra Operations
| Operation | Symbol | Example |
|---|---|---|
SELECT |
Status = “Active”(Customer) | |
PROJECTION |
CustomerName, Status (Customer) | |
RENAME |
{old_name} | |
UNION |
gives all tuples in table and . | |
INTERSECTION |
gives all tuples both in and . | |
DIFFERENCE |
gives tuples in but not in . | |
CARTESIAN PRODUCT |
gives combinations of columns in and . | |
JOIN |
None |
Modification of Database
Operations of modifying databases:
- Deletion
- Insertion
- Updating
These operations are expressed using the assignment operator .
Deletion
Example:
Insertion
Example:
Updating
Updating can be expressed by a sequence of deletion and insertion operations.
Last updated on