Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 20

Relational Model :

Data Blending/Joins
Session Objective

At the end of this session , student should be able to


• Understand how data is maintained in relational model
• Understand different ways of merging information (blending) from
multiple sources
• Implement the concept of data blending using Tableau on a given
case study
Poll Question

An attribute is a __________ in a relation.


a) Row
b) Column
c) Value
d) Tuple
Data Blending-Importance in visualization
context
• In Relational Model , data is maintained in the form of rows
and columns which is most commonly called as relation or
Table.
• In Database, data is spread over multiple tables.
• Sometimes we may want data from two or more tables.
• Data blending is a method for combining data from multiple
sources.
• Data blending brings in additional information from a
secondary data source and displays it with data from the
primary data source directly in the view.
Step 1: Create and Insert data in Table 1
Step 2: Create and Insert data in Table 2
Step 3: Drag and drop the first table or left table
to the field region.
• To describe how
to join data in
Tableau, we need
at least two
tables.
• First, Drag and
drop the first
table or left the
table to the field
region.
• In this example,
we are using our
Employee table as
a left table
Step 4: Drag and drop the second table or
right table to the field region.
• Drag and drop the
second table or
right table to the
field region.
• When you
dragged the
Department table,
a pop-up window
will be opened to
select the Join
type and Joining
key, as shown in
adjacent figure.
Different Types of JOINs
• (INNER) JOIN: Returns records that have matching values in both
tables
• LEFT (OUTER) JOIN: Return all records from the left table, and the
matched records from the right table
• RIGHT (OUTER) JOIN: Return all records from the right table, and the
matched records from the left table
• FULL (OUTER) JOIN: Return all records when there is a match in
either left or right table
INNER JOINS

• An inner join of Tables A and B


gives the result of A intersect B,
• Inner joins use a comparison
operator to match rows from
two tables based on the values
in common columns from each
table

Select the Dept ID column


from the Employee table
as shown
INNER JOINS

Select the Id column


from department
table as shown
INNER JOIN

• Created a simple table


report with Occupation, Last
name, Department name,
First name on Rows and
Sales Amount, and Yearly
income on columns
• Inner Join produced 10
Rows, which includes all the
matching records from
Employee and Department
table.
LEFT JOIN

• Left Join is producing 14


Rows.
• It includes all the records
from the Employee table
and matching records from
the Department table.
• Remember, four non-
matching records from
Department table will be
displayed as Nulls
RIGHT JOIN

• Right Join is producing 12


Rows.
• Output includes all records
from the Department table
and matching records from
the Employee table.
• Two non-matching records
from the Employee table
will display as Nulls
FULL OUTER JOIN

• FULL OUTER JOIN returns a


result set that includes rows
from both left and right tables.
• When no matching rows exist
for the row in the left table, the
columns of the right table will
have nulls
• Full Outer Join is producing 16
Rows.
Blend your data – Web Reference

The following reference provides step wise guidance for


Data Blending :
https://help.tableau.com/current/pro/desktop/en-
us/multiple_connections.htm
Case Study

For the
given case
study ,
perform the
following
Join
operations
in SQL and
Tableau
1)Inner
2)Left
3)Right
4)Full Outer
Poll Question

Q. Which of the following statements are False?


A. RIGHT OUTER JOIN is equivalent to LEFT OUTER JOIN if
order of tables are reversed
B. FULL OUTER JOIN is same as CROSS JOIN
C. SELF JOIN is a special type of OUTER JOIN
D. Both B and C

You might also like