What is the projection operation in DBMS?

The projection operator π\pi is one of the unary operators in relational algebra (RA) and is used to project columns from a relation. It can select specific columns from a given relation and hide all the other columns.

This relational operator is a base for SQL (Structured Query Language) and is used to write queries. The projection operator is also known as vertical partitioning.

Note: The projection operator is always written in the last of a RA query. It encapsulates the query containing other operators.

Syntax

A projection query looks like this:

The attribute listattribute \space list contains the column names that are to be extracted from a table or joined tables RR.

Examples

Let's look at a few examples to make things clear:

Example 1

Consider the following table:

Students

StudentID

StudentName

CGPA

1

John

3.45

2

Harry

3.50

3

Elizabeth

3.21

4

Charlie

2.94

The above table holds the data of a few students. Suppose we only want the names and CGPA of the students, so:

The result of the query above will be:

StudentName

CGPA

John

3.45

Harry

3.50

Elizabeth

3.21

Charlie

2.94

Example 2

Consider another table:

Customers

CustomerID

CustomerName

Email

1

John

jhwork80@gmail.com

2

Harry

harrypotter456@gmail.com

3

Harry

harryowens3@gmail.com

4

Charlie

charliechap@gmail.com

We apply the following projection operation to the table above:

The result will be:

CustomerName

John

Harry

Charlie

We see that the projection operator gives distinct values, even though both the customers' named Harry are two different people with different IDs.

Characteristics

The following are some characteristics of the projection operator:

  • It extracts columns from the original relation.

  • It removes all the duplicate attributes while projecting the output table.

  • The projection operation is not commutative.

  • The cardinality (rows) of the projected table/relation may or may not be equal to the original table/relation.

  • The projection operator translates to the SELECT DISTINCT operation followed by FROM in SQL.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved