The Relational Algebra

It is a procedural query language. It consists of a set of operations that take one or two relations as input and produce a new relation as their result.  The fundamental operations in relational algebra are select, projects, union, set difference, cartesian product, and rename.


Selection-

This operation returns tuples from a single relation based on the specified predicate (condition). Multiple predicates can be added using AND, OR, and NOT.


Projections-
This operation returns a relation that contains a vertical subset of used relation. In other words, it returns a set of tuples only with specified attributes.


Cartesian Product-
This operation creates a relation combining two relations, concatenating every tuple in one relation with every tuple in another relation. In simple terms, if the first table has 100 records with 5 attributes and the other table has 50 records with 10 attributes, this creates an output with 5000 records (100 * 50) and 15 attributes (5 + 10).


Union-

This operation makes a relation containing all tuples from the first relation or second relation or both first and second relations. This eliminates duplicates. Remember, both relations used must be union-compatible.


Set Difference-

This operation creates a relation containing tuples in the first relation that are not in the second relation. Just like the previous one, both relations must be union-compatible. 

Rename-

The rename operation allows us to rename the output relation. 'rename' operation is denoted with small Greek letter rho ρ.

Post a Comment

0 Comments