Explain Intersection Operation in Relational Algebra



Query is a question or requesting information. Query language is a language which is used to retrieve information from a database.

Query language is divided into two types −

  • Procedural language

  • Non-procedural language

Procedural language

Information is retrieved from the database by specifying the sequence of operations to be performed.

For Example − Relational algebra.

Structure Query language (SQL) is based on relational algebra.

Relational algebra consists of a set of operations that take one or two relations as an input and produces a new relation as output.

Types of Relational Algebra operations

The different types of relational algebra operations are as follows −

  • Select operation

  • Project operation

  • Rename operation

  • Union operation

  • Intersection operation

  • Difference operation

  • Cartesian product operation

  • Join operation

  • Division operation

Union, intersection, difference, cartesian, join, division comes under binary operation (operate on two tables).

Intersection operation

It displays the common values in R1 & R2. It is denoted by ∩.

Syntax

regno(R1) ∩ ∏regno(R2)

Consider two sets,

A={1,2,4,6} and B={1,2,7}

Intersection of A and B

A ∩ B ={1,2}

Elements that are present in both sets A and B are present in the set obtained by intersection of A and B.

In relational algebra if R1 and R2 are two instances of relation then,

R1 ∩ R2 ={ x | x€ R1 and x € R2}

That is, the intersection of R1 and R2 only those tuples will be present that are in both R1 and R2

Example

Find all the customers whose account is in the bank and have taken out a loan.

The expression is as follows −

∏Name(Depositor) ∩ ∏Name(Borrower)

Depositor

ID Name
1 A
2 B
3 C

Borrower

ID Name
2 B
3 A
5 D

So, the intersection of depositor and borrower is as follows −

A
B
Updated on: 2021-07-06T15:43:31+05:30

10K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements