Prev Next
First learn about procedural and non-procedural query language: procedural and non-procedural query language
Relational Algebra:
Relational Algebra is a procedural query language which take relation as input and gives relation as output.
It uses various operation to perform this action. It is performed recursively on a relation and intermediate results are also considered as relations.
Video on Relational Algebra: Relational Algebra
Theory:
database-management-system-relational-algebra
relational-algebra-dbms
basic-operators-in-relational-algebra
extended-operators-in-relational-algebra
dbms-row-oriented-vs-column-oriented-data-stores
Types of operations in relational algebra:
1. Basic/fundamental operations - Select, project, Union, Set Difference, Cartesian product, Rename.
2. Derived operations - Join (Natural, Left, Right, Full), Intersection, Division.
1. Basic/Fundamental operations:
a. Select (σ):
It selects tuples that satisfy the given predicate/condition from a relation.
It is Unary operator which can take one table at a time.
Syntax:
e.g. Find the details of Student who live in Rohini
Video on Select operation:
1. Select operation1
2. Select operation2
b. Project (π):
It selects the desired columns from a relation.
It is Unary operator which can take one table at a time.
Syntax:
e.g. Find all student name along with their rank
1. Video on Project Operation: Project Operation
2. Select and Project operations examples: Select and Project operations
c. Union (U):
It works on multiple tables. It includes all the tuples that are in table A or in B. Union helps to remove duplicate tuples.
Syntax: A U B
Video on Union: Union
d. Set difference (-):
If A - B, then the result of this includes all the tuples that are in A but not in B.
If B - A, then the result of this includes all the tuples that are in B but not in A.
Video on Set difference: Set difference
e. Cartesian product (X):
It is helpful to merge columns from two relations.
Video : Cartesian product
Problems: Problems in Cartesian product
f. Rename (ρ):
Result of relational algebra is relation but without any name so, rename operations helps in that. Rename operation helps to rename the output relation.
2. Derived operations:
a. Natural Join:
Video on Natural Join Natural Join
A Natural Join is a join operation in which 2 tables are joined based on all common columns.
b. Left Outer Join:
It returns all records from the left relation and matched records from the right relation and if there is no match then the result is null from the right side.
c. Right Outer Join:
It returns all records from the right table and matched records from the left table and if there is no match then the result is null from the left side.
d. Full Outer Join:
It returns all matching records from both tables whether the other matches or not.
Outer Join or Full Outer join: Outer Join or Full outer join
Join or Inner Join: Join or Inner Join
Join or Inner Join with 'ON' operation: Join or Inner Join with 'ON' operation
e. Intersection (∩):
Records that are present in both the relation A and B will only present in the set obtained by intersection of A and B (i.e. common tuple in both relation).
f. Division:
Extended operators in Relational Algebra: Extended operators in Relational Algebra