
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Project 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
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:
Regno | Branch | Section |
---|---|---|
1 | CSE | A |
2 | ECE | B |
3 | CIVIL | B |
4 | IT | A |
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 −
Branch | Section |
---|---|
CSE | A |
ECE | B |
CIVIL | B |
IT | A |
To display regno, section of ECE students, use the following command −
∏regno,section(σbranch=ECE(student))
Output
Regno | Section |
---|---|
2 | B |
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)