Normalization For Relational Database Part 4 42
Normalization For Relational Database Part 4 42
co
1
www.gradeup.co
Content :-
1. Binary Operations
a. Union
b. Intersection
c. Set Difference
d. Cartesian Product
2. Joins
UNION : The result of this operation , denoted by R U S, is a relation that includes all the
tuples that are either in R or in S or in both R and S. Duplicate tuples are eliminated .
Table R
Name Address
Ram U.P.
Shaym Haryana
Mohan Delhi
Table S
Name Mobile No.
Ram 9999999393
Shyam 9999999563
S.K. 8899999393
Shruti 9999779393
Intersection :-The result of this operation , denoted by R ∩ S is a relation that includes all
the tuples that are common in both R and S.
∏ NAME (R) ∩ ∏ NAME (S)
Name
Ram
Shaym
Set Difference (or MINUS):- The result of this operation , denoted by R-S , is relation
that includes all the tuples that are in R but not in S.
∏ NAME (R) - ∏ NAME (S)
Name
Mohan
Cartesian product:- It is also known as cross product or cross join which is denoted by X .
It is used to combine each row of one table with the each row of other table .
Employee :
Name Salary
2
www.gradeup.co
Ram 10000
Shaym 20000
Mohan 5000
Department :-
Dprt_No. Dprt_Name
1 H.R.
2 Management
3 IT
Employee X Department
Name Salary Dprt_No. Dprt_Name
Ram 10000 1 H.R.
Ram 10000 2 Management
Ram 10000 3 IT
Shaym 20000 1 H.R.
Shaym 20000 2 Management
Shaym 20000 3 IT
Mohan 5000 1 H.R.
Mohan 5000 2 Management
Mohan 5000 3 IT
Join Operations:A Join operation combines related tuples from different relations, if and
only if a given join condition is satisfied. It is denoted by ⋈.
Join Operation
Outer Join
Left Outer Join
Employee :-
Emp_Code EMP_Name
001 Sam
f
002 Jerry
003 Hack
Salary :-
t
3
www.gradeup.co
Emp_code Salary
001 50000
002 60000
003 35000
1. Natural Join:
A natural join is the set of tuples of all combinations in R and S that are equal on their
common attribute names.
It is denoted by ⋈.
Example: Let's use the above EMPLOYEE table and SALARY table:
∏EMP_NAME, SALARY (EMPLOYEE ⋈ SALARY)
2. Outer Join :
The outer join operation is an extension of the join operation. It is used to deal with missing
information.
EMPLOYEE
EMP_NAME STREET CITY
Riya Civil Line Delhi
Suman M.G. Street Bengaluru
Shyam Nehru Nagar Mumbai
Ravi Park street Chennai
FACT_WORKERS
EMP_NAME BRANCH SALARY
Riya HCL 15000
Suman WIPRO 20000
Shyam INFOSYS 30000
Kulbir TCS 10000
EMPLOYEE ⋈ FACT_WORKERS
EMP_NAME STREET CITY BRANCH SALARY
Riya Civil Line Delhi HCL 15000
Suman M.G. Street Bengaluru WIPRO 20000
Shyam Nehru Nagar Mumbai INFOSYS 30000
4
www.gradeup.co
Equi Join:-It is also known as an inner join. It is the most common join. It is based on
matched data as per the equality condition. The equi join uses the comparison operator(=)
Example :-
Customer
C_ID NAME
1 Heena
2 Reena
3 Hari
5
www.gradeup.co
4 Saurbh
Product
Product_ID City
1 Delhi
2 Mumbai
3 U.P.
4 H.P.
Customer ⋈ Product
6
www.gradeup.co