Explain intersection operation in relational algebra (DBMS)?


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

IDName
1A
2B
3C

Borrower

IDName
2B
3A
5D

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

A
B

Updated on: 06-Jul-2021

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements