Relational algebra is a procedural query language that provides a theoretical foundation for relational databases and SQL. It defines operators that transform one or more input relations into an output relation, which can be combined to express complex queries that transform multiple input relations into a single output relation. Relational algebra is performed recursively on a relation, and intermediate results are also considered relations. The fundamental operations of relational algebra are:
- Select: This operator selects required tuples of the relations based on certain conditions.
- Project: This operator retrieves required attributes (columns) from the relation.
- Union: This operator combines tuples from two relations, and duplicates are eliminated.
- Set Intersection: This operator returns tuples that are common in two relations.
- Set Difference: This operator returns tuples that are present in one relation but not in the other.
- Cartesian Product: This operator returns all possible combinations of tuples from two relations.
- Rename: This operator is used to rename the output relation.
Relational algebra is a procedural query language, which means that it specifies both "what to do" and "how to do it". It is used to access data from a database by specifying the method/procedure in the query. Relational algebra is the fundamental block for modern language SQL and modern Database Management Systems such as Oracle Database, Microsoft SQL Server, IBM Db2, etc. .