# Explain project operation in relational algebra (DBMS)?

DBMSDatabaseBig Data Analytics

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

Select, project, rename comes under unary operation (operate on one table).

## Projection operation

It displays the specific column of a table. It is denoted by pie (∏). It is a vertical subset of the original relation. It eliminates duplicate tuples.

### Syntax

The syntax is as follows −

∏regno(student)

## Example

Consider the student table:

RegnoBranchSection
1CSEA
2ECEB
3CIVILB
4ITA

To display regno column of student table, we can use the following command −

∏regno(student)

### Output

RegNo
1
2
3
4

To display branch, section column of student table, use the following command −

∏branch,section(student)

The result is as follows −

BranchSection
CSEA
ECEB
CIVILB
ITA

To display regno, section of ECE students, use the following command −

∏regno,section(σbranch=ECE(student))

### Output

RegnoSection
2B

Note: Conditions can be written in select operation but not in projection operation.

Consider the employee table to know more about projection.

• If no condition is specified in the query then, Π empid, ename, salary, address, dno (emp).

• If condition is specified then, the composition of the select and projection is as follows −

∏ empid, ename, salary, address, dno (σ salary >20,00 ^ LOC = HOD ^ dno=20) (emp)