Professional Documents
Culture Documents
Class - 2 - DBMS
Class - 2 - DBMS
Malay Bhattacharyya
Assistant Professor
1 Preliminaries
2 Operations on Sets
4 Special Operations
5 Extended Operations
6 Completeness
Outline Preliminaries Operations on Sets Unary and Binary Operations Special Operations Extended Operations Completeness
Preliminaries
Preliminaries
Example of a relation:
Preliminaries
Union
Union
Intersection
Intersection
Difference
Difference
Difference
Lemma
Given a pair of relations R1 and R2, the set difference operation
R1 − R2 monotonically increases with respect to R1 but
monotonically decreases with respect to R2.
Outline Preliminaries Operations on Sets Unary and Binary Operations Special Operations Extended Operations Completeness
Difference
Lemma
Given a pair of relations R1 and R2, the set difference operation
R1 − R2 monotonically increases with respect to R1 but
monotonically decreases with respect to R2.
Lemma
Cartesian product monotonically increases with respect to the
relations on which they are applied in relational algebra.
Outline Preliminaries Operations on Sets Unary and Binary Operations Special Operations Extended Operations Completeness
Lemma
Cartesian product monotonically increases with respect to the
relations on which they are applied in relational algebra.
R1 ⊆ R2 ∧ R3 ⊆ R4 ⇒ R1 × R3 ⊆ R2 × R4 .
Let us brainstorm!!!
Let us brainstorm!!!
Selection
Selection
Projection
Projection
Gold Silver
0 0
0 3
0 2
1 1
2 3
0 1
1 4
Year Silver
2012 3
Outline Preliminaries Operations on Sets Unary and Binary Operations Special Operations Extended Operations Completeness
Rename
Rename – A caution
Outline Preliminaries Operations on Sets Unary and Binary Operations Special Operations Extended Operations Completeness
Rename
Example: ρIMO (MATH OLYMPIC)
Table: IMO
Year Gold Silver
2008 0 0
2009 0 3
2010 0 2
2011 1 1
2012 2 3
2013 0 2
2014 0 1
2015 0 1
2016 0 1
2017 0 0
2018 0 3
2019 1 4
Outline Preliminaries Operations on Sets Unary and Binary Operations Special Operations Extended Operations Completeness
Natural join
R1 ./ R2 = πA(R1 )∪A(R2 )) (σA1 (R1 )=A1 (R2 )∧...∧An (R1 )=An (R2 ) (R1 ×R2 )).
Natural join
Year
2011
2012
2019
Outline Preliminaries Operations on Sets Unary and Binary Operations Special Operations Extended Operations Completeness
A1 A2 A2 A3
Table: SYM 1 pi Table: VAL pi 22/7
2 e pi 333/106
Theta join
R1 ./θ R2 = σθ (R1 × R2 ).
EQUI join
Division
Division
Example: Let us consider the following pair of relations.
Table: CODE
Roll Coding Feature
1 Python Programming Table: SKILL
2 C Programming Feature
2 R Programming
Programming
3 Python Programming
Visualization
3 Python Visualization
4 C++ Programming
5 R Visualization
CODE ÷ SKILL
Roll Coding
3 Python
Outline Preliminaries Operations on Sets Unary and Binary Operations Special Operations Extended Operations Completeness
Assignment
Example: Gold ← E
Outline Preliminaries Operations on Sets Unary and Binary Operations Special Operations Extended Operations Completeness
R1 ./ R2
σP (R1 × R2 )
Outer join has been extended from the natural join operation for
avoiding information loss. Let us consider the following pair of
relations.
Let us brainstorm!!!
Let us brainstorm!!!
Note: The natural join of a relation R with itself will return the
original relation R.
Outline Preliminaries Operations on Sets Unary and Binary Operations Special Operations Extended Operations Completeness
Let us brainstorm!!!
Let us brainstorm!!!
Completeness
Completeness – An example
Completeness – An example
Completeness – An example
Completeness – An example