You are on page 1of 4

Lab No: 4

Joins

Name of the Student: Sahish Ashok Pandav Div. & Roll No. C-33 .

Title:- Execute DDL statements which demonstrate the use of views. Try to update the bas
e table using its corresponding view. Perform view creation from multiple tables.

Description:-

The database joins has the ability of combining two or more data tables/tuples into a single
table/tuple only if the following conditions are satisfied.
There must be a common attribute in both the tables .
Join must be satisfied.

Database joins can be broadly classified into two categories:

Inner Joins: 1) Theta Join


2) Natural Join

Outer Joins: 1) Left Outer Join


2) Right Outer Join

Results:

1. Equi Join
Customer Table:

Policy Table:
select Customers.FirstName, Customers.LastName, Policy.EffectiveDate
from Policy inner join Customers
on Policy.CustomerID = Customers.CustomerID;

2. Theta Join:
mobile table:

laptop table:

select mobile.mModel, laptop.lModel


from mobile join laptop
on mobile.mPrice > laptop.lPrice
order by mobile.mModel;

3. Natural Join:
4. Customer Table:
Policy Table:

select Customers.FirstName, Customers.LastName, Policy.EffectiveDate


from Policy inner join Customers
on Policy.CustomerID = Customers.CustomerID;

5. Left Outer Join


Customer Table

Policy Table
SELECT Customers.FirstName, Policy.PolicyType
FROM Customers
LEFT JOIN Policy ON Customers.CustomerID = Policy.CustomerID
ORDER BY Customers.FirstName;

6. Right Outer Join


Customer Table

Policy Table

SELECT Customers.FirstName, Policy.PolicyType


FROM Customers
RIGHT JOIN Policy ON Customers.CustomerID = Policy.CustomerID
ORDER BY Customers.FirstName;

You might also like