4. INTRODUCTION
• It was established by
E.F. Codd in 1971 as
the foundation for
query languages like
SQL.
5. INTRODUCTION
Think of it as a "procedural
language" that instructs the
database system on how to
construct new relations from
existing ones.
6. SELECTION
• Select operation chooses the subset of
tuples from the relation that satisfies the
given condition mentioned in the syntax of
selection.
• The selection operation is also known as
horizontal partitioning since it partitions the
table or relation horizontally.
7. KEY POINTS
• Relational algebra: focuses on
operations and logic.
• SQL: adds syntax, keywords, and
features specific to a particular
database system.
Differentiation from SQL's SELECT statement:
8. KEY POINTS
• where ‘c’ is selection condition which is a
boolean expression(condition), we can have a
single condition like Roll= 3 or combination of
condition like X>2 AND Y<1, symbol ‘σ (sigma)’
is used to denote select(choose) operator, R is a
relational algebra expression, whose result is a
relation.
Notation:
9. KEY POINTS
Correspondence:
• in SQL corresponds to selection in relational
algebra.
• * means all attributes, similar to selecting all
columns.
13. PROJECTION
OPERATION
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.
14. PROJECTION
OPERATION
Notation:
• where ‘A’ is the attribute list, it is the desired set of attributes
from the attributes of relation(R).
• Symbol ‘π(pi)’ is used to denote the Project operator, R is
generally a relational algebra expression, which results in a
relation.
18. SET OPERATIONS
Union
• For R ∪ S, 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.
21. SET OPERATIONS
The intersection of the sets A and B,
denoted by A ∩ B, is the set of elements
that belong to both A and B i.e. set of
the common elements in A and B.
Intersection
23. SET OPERATIONS
Difference
The difference between sets is denoted
by ‘A – B’, which is the set containing
elements that are in A but not in B. i.e.,
all elements of A except the element of
B.
28. JOINS
Notice that the "CustomerID"
column in the "Orders" table
refers to the "CustomerID" in
the "Customers" table. The
relationship between the two
tables above is the
"CustomerID" column.
29. JOINS
Then, we can create the following SQL statement (that contains an
INNER JOIN), that selects records that have matching values in both
tables: