The document defines and describes the common operations of relational algebra: selection, projection, union, set difference, cartesian product, and rename. Selection selects tuples from a relation based on a predicate. Projection extracts a vertical subset of attributes from a relation. Union combines the tuples of two relations while eliminating duplicates. Set difference returns tuples in the first relation that are not in the second. Cartesian product concatenates every tuple of one relation with every tuple of another. Rename allows renaming the output relation and attributes.
3. What is relation algebra?
The relational algebra is a theoretical procedural query language which
is collection of operation that we apply on our (relation) each operation
take one or more relation and through the usage of some operand we
produce another relation.
The relational algebra we perform many operation.
Unary.
Binary.
9/18/2018 3
5. There are several differences of syntax for relational algebra commands,
and you use a common symbolic notation for the commands and present it
informally.
The primary operations of relational algebra are as follows:
Select
Project
Union
Set different
Cartesian product
Rename
9/18/2018 5
6. Selection:-
It selects tuples that satisfy the given predicate from a relation
It is represented by sigma sign “σ”
This selection operation functions on a single relation R and
describes a relation which contains only those tuples of R that
satisfy the specified condition (predicate).
9/18/2018 6
7. projection:-
The Projection operation works on a single relation R and defines a relation
that contains a vertical subset of R, extracting the values of specified
attributes and eliminating duplicates.
It is represented by Greek sign pay “Π”
In this example, the Projection operation defines a relation that contains
only the chosen for attributes i.e. Relation is (Employ) staff No, f-Name, l-
Name, and salary, in the specified order
9/18/2018 7
8. union:-
The union of two relations R and S defines a relation that contains all
the tuples of R, or S, or both R and S, duplicate tuples being
eliminated. R and S must be union-compatible.
For a union operation to be applied, the following rules must hold .
It is represented by “∪”
r and s must have the same quantity of attributes.
Attribute domains must be well-matched.
Duplicate tuples get automatically eliminated.
i.e
Π name (relation 1) u Π name (relation 2)
9/18/2018 8
9. Set different:-
For R − S The Set difference operation defines a relation
consisting of the tuples that are in relation R, but not in S. R
and S must be union-compatible.
It is represented by “−”.
i.e
Π name (relation 1) - Π name (relation 2)
9/18/2018 9
10. Cartesian:-
For R × S, the Cartesian product operation defines a relation that is the
concatenation(link togather) of every tuple of relation R with every tuple
of relation S.
It is used to cerate multiple tuple between two relation.
It is represented by “x”.
9/18/2018 10
11. rename:-
The results of relational algebra are also relations but
without any name. The rename operation provides database
designers to rename the output relation.
Rename relation & attribute name
The rename-operation is denoted using small Greek letter
rho (ρ).
i.e we have a two relation student and grade we have a
query I want to find a student name have grad A
9/18/2018 11
12. 9/18/2018 12
Π name[σ grad =A (student x grade)]
(Rename operation)
ρ student grade [σ grad =A (student x grade)]
13. 9/18/2018 13
ρ a1/a2 (Relation)
Let suppose we have a relation (student) attribute Stdid and
Sname
ρ id/ student id (student)
Renmae attribute