This document discusses different types of joins in relational databases including inner joins (theta, equi, natural), outer joins (left, right, full) and self joins. Inner joins return tuples that match the join condition, while outer joins also return non-matching tuples with null values. Specific types of inner joins include theta joins with general comparison operators, equi joins using equality comparisons, and natural joins that automatically match on common attributes. Outer joins extend inner joins to preserve all tuples from one or both relations. Self joins perform joins between a relation and an aliased copy of itself.
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Dbms 12: Join
1. Dr. Amiya Ranjan Panda
Assistant Professor [II]
School of Computer Engineering,
Kalinga Institute of Industrial Technology (KIIT),
Deemed to be University,Odisha
Join
KALINGA INSTITUTE OF INDUSTRIAL
TECHNOLOGY
School Of Computer
Engineering
4 Credit Lecture Note 12
3. Ø The generalized-projection operation extends the projection operation by
allowing arithmetic functions to be used in the projection list. The general form
of generalized-projection is:
πF1,F2...Fn (E)
Ø Ex: Emp=(ssn, salary, deduction, years_service) be a relation. A report may be
required to show net_salary=salary-deduction, bonus=2000*years_service and
tax=0.25*salary
REPORT ← ρ (ssn,net_salary,bonus,tax) (πssn,salary−deduction, 2000∗ years_service, 0.25 ∗ salary (Emp))
3
Generalized Projection
4. Ø Aggregate functions take a collection of values and return a single value as a
result. NULL value will not participate in the aggregate functions. The general
form of aggregate function is:
grouping_attribute gaggregate_functions (R)
4
Aggregate Functions (g)
5. Ø The join operation is used to connect data across relations. Tables are joined on
columns that have the same data type and data width in the tables.
Ø Join operation joins two relations by merging those tuples from two relations
that satisfy a given condition. The condition is defined on attributes belonging
to relations to be joined.
Ø Different categories of join are:
ü Inner Join
ü Outer Join
ü Self Join
Ø Inner Join: In the inner join, tuples with NULL valued join attributes do not
appear in the result. Tuples with NULL values in the join attributes are also
eliminated. The different types of inner join are:
ü Theta Join
ü Equi Join
ü Natural Join
5
Join
6. Ø The theta join is a join with a specified condition involving a column from each
relation. This condition specifies that the two columns should be compared in
some way.
Ø The comparison operator can be any of the six: <, ≤, >, ≥, = and ^ =
Ø Theta join is denoted by (⋊ ⋉ θ) symbol. The general form of theta join is:
R ⋊ ⋉ θ S = π all (σ θ (R × S))
ü Degree (Result) = Degree (R) + Degree (S)
ü Cardinality (Result) ≤ Cardinality(R) × Cardinality(S)
6
Theta Join( θ )
8. 8
Equi Join( = )
Ø The equi join is the theta join based on equality of specified columns. That
means the equi join is the special type of theta join where the comparison
operator is =.
Ø The general form of theta join is: R ⋊⋉ = S = πall (σ = (R × S))
üDegree (Result) = Degree (R) + Degree (S)
üCardinality (Result) ≤ Cardinality(R) × Cardinality(S)
9. 9
Natural Join ( )
Ø To perform natural join on two relations, they should contain at least one
common attributes. It is just like the equi join with the elimination of the
common attributes. The natural join is denoted by (⋊ ⋉ ) symbol.
Ø The general form of theta join is:
R ⋊ ⋉ S = Π all−common_attributes (σ = (R × S))
üDegree (Result) = Degree (R) + Degree (S) - Degree (R ∩S)
üCardinality (Result) ≤ Cardinality(R) × Cardinality(S)
Ø The general form of the natural join can also be represented as:
R ⋊ ⋉ S = Π all (R ⋊ ⋉ S)
11. 11
Outer Join
Ø It is an extension of the natural join operation to deal with the missing
information. The outer join consists of two steps:
ü First, a natural join is executed
ü Then if any record in one relation does not match a record from the other
relation in the natural join, that unmatched record is added to the join
relation, and the additional columns are filled with NULLs
Ø The different types of outer join are:
ü Left Outer Join
ü Right Outer Join
ü Full Outer Join
12. 12
Left Outer Join
Ø The left outer join preserves all tuples in left relation. The left outer join is
denoted by symbol:
Ø All information from the left relation is present in the result of the left outer
join.
14. 14
Right Outer Join
Ø The right outer join preserves all tuples in right relation. The right outer join is
denoted by symbol:
Ø All information from the right relation is present in the result of the right outer
join.
15. 15
Full Outer Join
Ø The full outer join preserves all tuples in both relations. The full outer join is
denoted by symbol:
Ø All information from both the relations is present in the result of the full outer
join.
16. 16
Self Join
Ø The self join is similar to the theta join. It joins a relation to itself by a condition.
The self join can be viewed as a join of two copies of the same relation.
Ø The general form of self join is:
Ø Thus, the self join creates two alias or copies of the same relation; then
performs the theta join by a condition based on the attributes of these two
copies.