Professional Documents
Culture Documents
Lab 11 SQL JOINS INNER SELF OUTER
Lab 11 SQL JOINS INNER SELF OUTER
Lab 11 SQL JOINS INNER SELF OUTER
Lab-11
SQL JOINS INNER and SELF
Lab 11: SQL JOINS INNER, and SELF
Contents
1. Introduction .............................................................................................................................................................2
1.1 Relevant Lecture Material ...................................................................................................................................2
2. Activity Timeboxing ...............................................................................................................................................2
3. Objective of theexperiment .....................................................................................................................................2
4. ConceptMap ............................................................................................................................................................2
4.1 SELECT with JOIN ............................................................................................................................................2
4.2 INNER JOIN .......................................................................................................................................................7
4.3 SELF JOIN ..........................................................................................................................................................9
5. Homework beforeLab ...........................................................................................................................................10
5.1 Problem Solution Modeling ..............................................................................................................................10
5.2 Practices from home..........................................................................................................................................10
6. Procedure &Tools .................................................................................................................................................10
6.1 Tools..................................................................................................................................................................10
6.2 Setting-up and Setting Up XAMPP (MySQL, Apache) [Expected time = 5mins] ...........................................10
6.3 Walkthrough Task [Expected time = 30mins] ..................................................................................................11
7. PracticeTasks.........................................................................................................................................................12
7.1 Practice Task 1 [Expected time = 40mins]........................................................................................................12
7.2 Outcomes ..........................................................................................................................................................12
8. EvaluationTask(Unseen) [Expected time = 55mins for two tasks] .......................................................................12
8.1 Evaluation criteria .............................................................................................................................................12
9. FurtherReading......................................................................................................................................................13
9.1 Text Book ..........................................................................................................................................................13
9.2 Slides .................................................................................................................................................................13
10. REFERENCES:.................................................................................................................................................13
10.1 SQL-99 Complete, Really, by Peter Gulutzan & Trudy Pelzer. .......................................................................13
1. Introduction
The purpose of this lab is to familiarize you to SQL Joins. The SQL Joins clause is used to
combine records from two or more tables in a database. A JOIN is a means for combining fields
from two tables by using values common to each. In this lab discuss the SQL joins.
2. Activity Timeboxing
3. Objective of theexperiment
4.ConceptMap
SELECT command can be used to query and join data from two related tables. For example, to
list the employee name (in employees table) and job title (in jobs table), we could join the two
= jobs.job_id;)
ALIASES
In the above query result, two of the columns have the same name "job_id". We could create
aliases for column names
To make it easier for you to understand each type of join, we will use the
t1 and t2 with the following structures:
Example,
Both t1 and t2 tables have the pattern column, which is also the common column
between tables.
The following statements insert data intoboth t1 and t2 tables:
INSERT INTO t1(id,pattern)
VALUES(1,'Divot'),
(2,'Brick'),
(3,'Grid');
In an inner join of two tables, each row of the first table is combined (joined) with every row of
second table. Suppose that there are n1 rows in the first table and n2 rows in the second table,
INNER JOIN produces all combinations of n1×n2 rows - it is known as Cartesian product or
Cross Product
The following statement uses the INNER JOIN clause tojoin t1 and t2 tables:
5. Homework beforeLab
You must solve the following problems at home before the lab.
After reading the reference material mentioned in the introduction, now you are ready to perform
homework assigned to you.
Problem 1:
Problem 2:
Task-1
Task-2
6. Procedure &Tools
In this section, you will study how to make and run a customized exception.
6.1 Tools
6.2 Setting-up and Setting Up XAMPP (MySQL, Apache) [Expected time = 5mins]
This task is designed to guide you towards to understanding of inner and self joins.
7. PracticeTasks
This section will provide more practice exercises which you need to finish during the lab. You
need to finish the tasks in the required time. When you finish them, put these tasks in the
following folder:
\\fs\assignments$\IDBS\Lab10$
7.1 Practice Task 1 [Expected time = 40mins]
Consider the schema given in Lab01 (7.1 Practice Task), write down following SQL queries.
You can use data types of your ownchoice.
7.2 Outcomes
After completing this lab, student will be able to understand the usage inner and self joins.
The lab instructor will give you unseen task depending upon the progress of the class.
The evaluation criteria for this lab will be based on the completion of the following tasks. Each
task is assigned the marks percentage which will be evaluated by the instructor in the lab whether
the student has finished the complete/partial task(s).
9.1Text Book
Database Systems, A practical approach to design, implementation and management by Thomas
Connolly, Carolyn Begg, Addison Wesley , Fifth Edition,
9.2 Slides
The slides and reading material can be accessed from the folder of the class instructor available
at\\fs\lectures$\
10. REFERENCES: