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_ID | Name | Age | Department | District |
|---|---|---|---|---|
| 101 | Rafi Ahmed | 22 | CSE | Dhaka |
| 102 | Shanta Rahman | 21 | EEE | Khulna |
| 103 | Tanvir Hasan | 23 | CSE | Rajshahi |
| 104 | Sumaiya Akter | 20 | BBA | Dhaka |
| 105 | Imran Hossain | 24 | CSE | Chattogram |
🟩 Example 1: Displaying Only Name and Department
Operation:
πName, Department(Student)
Result:
| Name | Department |
|---|---|
| Rafi Ahmed | CSE |
| Shanta Rahman | EEE |
| Tanvir Hasan | CSE |
| Sumaiya Akter | BBA |
| Imran Hossain | CSE |
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, District(σDepartment='CSE'(Student))
Result:
| Name | District |
|---|---|
| Rafi Ahmed | Dhaka |
| Tanvir Hasan | Rajshahi |
| Imran Hossain | Chattogram |
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
| Feature | Description |
|---|---|
| Operator | π (Pi) |
| Purpose | Select specific attributes (columns) |
| Input | One relation |
| Output | Subset of columns from the same relation |
| SQL Equivalent | SELECT 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
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন