Relational Algebra – Projection (π) Operation in DBMS

Relational Algebra Operations – Projection (π)

In Relational Algebra, the Projection Operation is used to select specific columns (attributes) from a relation (table). It eliminates unwanted attributes and displays only the required information. Projection is similar to the SELECT column_list clause in SQL.


🔹 Definition

The Projection operation is a unary operation (works on a single relation). It selects only the specified attributes and removes duplicates automatically (if any).

Notation:

πattribute_list(Relation_Name)

Here, π (pi) denotes the projection operator, and the subscript lists the attributes (columns) you want to display.


🔹 Example (Bangladeshi Context)

Consider the following relation Student:

Student_IDNameAgeDepartmentDistrict
101Rafi Ahmed22CSEDhaka
102Shanta Rahman21EEEKhulna
103Tanvir Hasan23CSERajshahi
104Sumaiya Akter20BBADhaka
105Imran Hossain24CSEChattogram

🟩 Example 1: Displaying Only Name and Department

Operation:

πName, Department(Student)

Result:

NameDepartment
Rafi AhmedCSE
Shanta RahmanEEE
Tanvir HasanCSE
Sumaiya AkterBBA
Imran HossainCSE

Explanation: Only the columns Name and Department are projected (displayed).


🟩 Example 2: Displaying Unique Department Names

Operation:

πDepartment(Student)

Result:

Department
CSE
EEE
BBA

Explanation: The projection removes duplicate department values automatically.


🟩 Example 3: Displaying Name and District of CSE Students

Combined Operation:

πName, DistrictDepartment='CSE'(Student))

Result:

NameDistrict
Rafi AhmedDhaka
Tanvir HasanRajshahi
Imran HossainChattogram

Explanation: First, the selection (σ) filters CSE students, then projection (π) extracts only Name and District.


🔹 Properties of Projection

  • Projection extracts only the specified columns.
  • It automatically removes duplicate rows (sets are unordered and unique).
  • It is often used with Selection for complex queries.

🔹 SQL Equivalent

SELECT Name, Department FROM Student;
SELECT DISTINCT Department FROM Student;

✅ Summary Table

FeatureDescription
Operatorπ (Pi)
PurposeSelect specific attributes (columns)
InputOne relation
OutputSubset of columns from the same relation
SQL EquivalentSELECT column_list FROM table;

🔹 Real-Life Use (Bangladesh Example)

In a university database in Bangladesh, projection can be used to:

  • Display only Student Names and Districts for admission records.
  • List unique departments available at Dhaka University.
  • Generate a report of names and departments for final year CSE students.

relational algebra projection operation, pi operator example dbms, projection in relational algebra, dbms projection tutorial bangladesh, relational algebra with bangladeshi data, student table projection example, relational algebra notes

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন