Set Theory Operations in Relational Algebra

Last Updated : 26 Jul, 2025

Set theory operations in relational algebra are based on basic mathematical set operations. Unlike commands like SELECT, PROJECT or RENAME (which work on a single table), these are binary operations, meaning they work on two relations (or tables) at a time. They’re mainly used to combine, compare or filter data between two sets in different ways. Whether you're merging tables, finding common entries or identifying differences, set operations give you the tools to do it efficiently and logically. The set operation is mainly categorized into the following:

  1. Union operation
  2. Intersection operation
  3. Set difference or Minus operation

Before we apply one of the 3 set operations on relations, the two relations on which we are performing the operations must have same type of tuples. This is also known as be Union compatibility (or Type compatibility). 

Type compatibility:  Two relations A(P1, P2, ..., Pn) and B(Q1, Q2, ..., Qn) are said to be Type compatible (or Union compatible) if both the relation have the same degree 'k' and

domain(Pi) = domain(Qi) for 1<= i <= k.

1. UNION Operation:

Notation: A ∪ S

where, A and S are the relations, symbol ‘∪’  is used to denote the Union operator. The result of Union operation, which is denoted by A ∪ S, is a relation that basically includes all the tuples that are present in A or in S or in both, eliminating the duplicate tuples. 

Example :

R = {(1, 'Alice'), (2, 'Bob')}

S = {(2, 'Bob'), (3, 'Charlie')}

R ∪ S = {(1, 'Alice'), (2, 'Bob'), (3, 'Charlie')}

Important points on UNION Operation:

  • The UNION operation is commutative, that is :

A ∪ B = B ∪ A

  • The UNION is associative, that means it is applicable to any number of relation.

A ∪ ( B ∪ C ) = ( A ∪ B ) ∪ C

  • In SQL, the operation UNION is as same as UNION operation here.
  • Moreover, In SQL there is multiset operation UNION ALL.

2. INTERSECTION Operation:

Notations: A ∩ S

where, A and S are the relations, symbol ‘∩’  is used to denote the Intersection operator. The result of Intersection operation, which is denoted by A ∩ S, is a relation that basically includes all the tuples that are present in both A an S.

Example :

R = {(1, 'Alice'), (2, 'Bob')}

S = {(2, 'Bob'), (3, 'Charlie')}

R ∩ S = {(2, 'Bob')}

Important points on INTERSECTION Operation:

  • The INTERSECTION operation is commutative, that is :

A ∩ B = B ∩ A

  • he INTERSECTION is associative, that means it is applicable to any number of relation.

A ∩ ( B ∩ C ) = ( A ∩ B ) ∩ C

  • INTERSECTION can be formed using UNION and MINUS as follows:

A ∩ B = ((A ∪ B) - (A - B)) - (B - A)

  • In SQL, the operation INTERSECT is as same as INTERSECTION operation here.
  • Moreover, In SQL there is multiset operation INTERSECT ALL.

3. MINUS (or SET DIFFERENCE) Operation:

Notations: A - S

where, A and S are the relations, symbol ‘ - ’  is used to denote the Minus operator. The result of Intersection operation, which is denoted by A - S, is a relation that basically includes all the tuples that are present in A but not in S.

Example :

R = {(1, 'Alice'), (2, 'Bob')}

S = {(2, 'Bob'), (3, 'Charlie')}

R − S = {(1, 'Alice')}

Important points on MINUS (or SET DIFFERENCE) Operation:

  • The SET DIFFERENCE operation is not commutative, that means :

A - B != B - A

  • In SQL, the operation EXCEPT is as same as MINUS operation here.
  • Moreover, In SQL there is multiset operation EXCEPT ALL.

Explain with example

Consider a relation Student(FIRST, LAST) and Faculty(FIRSTN, LASTN) given below :

Table Student:

FirstLast
AishaArora
BikashDutta
MakkuSingh
RajuChopra

Table Faculty:

FirstNLastN
RajKumar
HoneyChand
MakkuSingh
KaranRao

1. Student UNION Faculty :

Student ∪ Faculty

FirstLast
AishaArora
BikashDutta
MakkuSingh
RajuChopra
RajKumar
HoneyChand
KaranRao

2. Student INTERSECTION Faculty :

Student ∩ Faculty

FirstLast
MakkuSingh

3. Student MINUS Faculty :

Student - Faculty

FirstLast
AishaArora
BikashDutta
RajuChopra

For more information about more operations you can refer to - Set theory operations.

Comment

Explore