**Relational Algebra Operators-**

Before you go through this article, make sure that you have gone through the previous article on **Introduction to Relational Algebra**.

The operators in relational algebra are classified as-

In this article, we will discuss about Projection Operator.

**Projection Operator-**

- Projection Operator (π) is a unary operator in relational algebra that performs a projection operation.
- It displays the columns of a relation or table based on the specified attributes.

**Syntax-**

π_{<attribute list>}(R) |

**Example-**

Consider the following Student relation-

ID |
Name |
Subject |
Age |

100 | Ashish | Maths | 19 |

200 | Rahul | Science | 20 |

300 | Naina | Physics | 20 |

400 | Sameer | Chemistry | 21 |

**Student**

Then, we have-

**Result for Query π**_{Name, Age}(Student)-

_{Name, Age}(Student)-

Name |
Age |

Ashish | 19 |

Rahul | 20 |

Naina | 20 |

Sameer | 21 |

**Result for Query π**_{ID , Name}(Student)-

_{ID , Name}(Student)-

ID |
Name |

100 | Ashish |

200 | Rahul |

300 | Naina |

400 | Sameer |

**Important Points-**

**Point-01:**

- The degree of output relation (number of columns present) is equal to the number of attributes mentioned in the attribute list.

**Point-02:**

- Projection operator automatically removes all the duplicates while projecting the output relation.
- So, cardinality of the original relation and output relation may or may not be same.
- If there are no duplicates in the original relation, then the cardinality will remain same otherwise it will surely reduce.

**Point-03:**

- If attribute list is a super key on relation R, then we will always get the same number of tuples in the output relation.
- This is because then there will be no duplicates to filter.

**Point-04:**

- Projection operator does not obey commutative property i.e.

π _{<list2>} (π _{<list1> }(R)) ≠ π _{<list1>} (π _{<list2> }(R))

**Point-05:**

- Following expressions are equivalent because both finally projects columns of list-1

π _{<list1>} (π _{<list2> }(R)) = π _{<list1> }(R)

**Point-06:**

**Selection Operator**performs horizontal partitioning of the relation.- Projection operator performs vertical partitioning of the relation.

**Point-07:**

- There is only one difference between projection operator of relational algebra and SELECT operation of SQL.
- Projection operator does not allow duplicates while SELECT operation allows duplicates.
- To avoid duplicates in SQL, we use “distinct” keyword and write SELECT distinct.
- Thus, projection operator of relational algebra is equivalent to SELECT operation of SQL.

**Next Article-** **Set Theory Operators in Relational Algebra**

Get more notes and other study material of **Database Management System (DBMS)**.

Watch video lectures by visiting our YouTube channel **LearnVidFun**.

Summary

Article Name

Projection Operator | Relational Algebra | DBMS

Description

Relational Algebra Operators- Projection Operator (π) is a unary operator in relational algebra that perform a projection operation. It displays the columns of a table or relation based on the specified attributes.

Author

Akshay Singhal

Publisher Name

Gate Vidyalay

Publisher Logo