0% found this document useful (0 votes)
17 views28 pages

Join Operation

The document discusses join operations in database management systems (DBMS), focusing on their objectives and types, including inner and outer joins. It explains how join conditions are used to combine rows from multiple tables based on related columns, and details specific types of joins such as natural, theta, and equi joins. Additionally, it outlines the characteristics of left, right, and full outer joins, and provides extra credit tasks related to MySQL operations.

Uploaded by

Kiran Kulkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views28 pages

Join Operation

The document discusses join operations in database management systems (DBMS), focusing on their objectives and types, including inner and outer joins. It explains how join conditions are used to combine rows from multiple tables based on related columns, and details specific types of joins such as natural, theta, and equi joins. Additionally, it outlines the characteristics of left, right, and full outer joins, and provides extra credit tasks related to MySQL operations.

Uploaded by

Kiran Kulkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Applications Database

Management

Join operation in DBMS


Dr. Lucy Nwosu
Agenda
 Announcement - Midterm
 DBMS Join operations
 Objectives
 Types of Join
 Inner Join
 Outer Join
Chapter 4 Entity Relationship (ER)
Modeling

Chapter 3 (pages 83 - 90)


Chapter 7 (pages 300 – 302)
DBMS Join Operation

Database Systems, 10th Edition 3


Objectives
 We will learn:
 The main types of join operation in DBMs
 The characteristics of the different types
grouped into inner and outer joins.
 How join type affects the database
retrieval result.

Database Systems, 10th Edition 4


A Join Operation
A join operation in a relational database
management system (RDBMS) is an operation
for combining rows from two or more tables
based on related columns between them. The
primary objective of a join is to retrieve data
from multiple tables simultaneously,
effectively performing a multi-table query.
Join Condition
• A join condition is a criteria used to determine how
rows from two or more tables should be combined.

• It specifies how the rows from different tables are


related. This is typically done by identifying the
columns in each table that contain related
information.

• These columns are often referred to as "foreign keys"


in one table and "primary keys" in the other, although
this is not a strict requirement.
Join Condition
1. Column Comparison: Join conditions compares
values in one or more columns between the tables
being joined. These columns often represent related
information, such as primary and foreign keys.
2. Equality Comparison: The most common type of join
condition involves checking for equality between the
values in the specified columns.
3. Multiple Conditions: It's possible to have join
conditions that involve multiple columns. For
example, you might join tables based on a
combination of two columns being equal and another
column meeting a specific condition
Types of Join Operation

Database Systems, 10th Edition 8


Types of Join Operation

Natural Join
Types of Join Operation
• Self Join: A table joins to itself.
• Cross join: Cartesian Product, there is no join condition

• Inner Join: Returns only the rows that have matching values in
both tables based on the join condition.
• If there is no match for a row in one
table, it is not included in the result set.
• Examples: Natural, Theta, EQUI
Inner Join
• Outer Join: Returns all the rows from one or both tables
involved in the join, regardless of whether there is a match
based on the join condition.
• If there is no match for a row in one table, the join operation includes
NULL values for the columns from the other table in the result set.
• Examples: Left, Right, Full
Inner Join: Natural Join (⋈)
• Natural join is a type of inner join in which there is no
need of any comparison operators.
• A natural join links tables by selecting only the rows
with common values in their common attribute(s).
• Columns should have the same name and domain. It
then combines the rows where the values in these
columns match.
• A natural join is the result of a three-stage process:
1. Create a PRODUCT of the tables
2. A SELECT is performed on the output of Step 1 to yield only the rows
for which the values are equal.
3. A PROJECT is performed on the results of Step 2 to yield a single copy
of each attribute, thereby eliminating duplicate columns.
Step 1
Step 2

Step 3
Inner Join: Theta (⋈θ)

• The theta join is considered an extension of natural


join. It is a conditional join that links tables on the
basis of an inequality comparison operator
(<, >, <=, >=) in the join condition that compares
specified columns of each table.
• It does not eliminate duplicate columns, and the
condition or criterion used to join the tables must be
explicitly defined.
Inner Join: Equi Jion
• Equijoin a join operator that links tables based on
an equality condition that compares specified
columns of the tables.

• The outcome of the equijoin does not eliminate


duplicate columns, and the condition or criterion
used to join the tables must be explicitly defined.

• The equijoin takes its name from the equality


comparison operator (=) used in the condition. If
any other comparison operator is used, the join is
called a theta join.
Outer Join: Left (⟕)
• A left outer join is a type of outer join that retrieves
all records from left table and retrieves the
matching record from right table.

• If there is no match, the result is NULL on the right


side
The left outer join yields all of the rows in the CUSTOMER
table, including those that do not have a matching value in the
AGENT table
Outer Join: Right (⟖)
• A right outer join is a type of outer join that retrieves
all records from right table and retrieves the
matching record from left table.

• If there is no match, the result is NULL on the left


side
A right outer join yields all of the rows in the AGENT
table, including those that do not have matching values
in the CUSTOMER table.
Outer Join: Full (⟗)
Full Outer Join (or Full Join): Returns all rows when
there is a match in either left or right table.

It combines the results of both the Left Join and the


Right Join. If there is no match, the result is NULL on
the side where there is no match.
Extra-Credit
Go To MySQL:

1. Update the PARENTS table with the attribute


(Number of Children), and insert the number of
children for each parent.

2. Create a table GRANDPARENTS, insert the


firstname, lastname, month_of_birth, address
and number-of-children for each grandparent.

3. Find: PARENTS U GRANDPARENTS

4. Share a screenshot of query and resulting tables


from 1, 2 & 3

You might also like