Relational Algebra Operations – Selection (σ)
In the Relational Algebra of DBMS, the Selection Operation is used to extract specific rows (tuples) from a relation (table) that satisfy a given condition.
It acts as a filtering operation, similar to the WHERE clause in SQL.
🔹 Definition
The Selection operation is a unary operation (applies on a single relation). It selects those rows that satisfy a specified predicate or condition.
Notation:
σcondition(Relation_Name)
Here, σ (sigma) denotes the selection operator, and the subscript specifies the condition.
🔹 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: Selecting Students from Dhaka
Operation:
σDistrict = 'Dhaka'(Student)
Result:
| Student_ID | Name | Age | Department | District |
|---|---|---|---|---|
| 101 | Rafi Ahmed | 22 | CSE | Dhaka |
| 104 | Sumaiya Akter | 20 | BBA | Dhaka |
Explanation: Only those tuples where District = 'Dhaka' are selected.
🟩 Example 2: Selecting CSE Students Aged Over 22
Operation:
σDepartment = 'CSE' AND Age > 22(Student)
Result:
| Student_ID | Name | Age | Department | District |
|---|---|---|---|---|
| 105 | Imran Hossain | 24 | CSE | Chattogram |
Explanation: The query selects only students from the CSE department whose age is greater than 22.
🔹 Common Selection Conditions
- Comparison: <, <=, >, >=, =, ≠
- Logical Operators: AND (∧), OR (∨), NOT (¬)
- Range Condition: BETWEEN, IN, etc.
Examples:
- σAge > 21(Student)
- σDepartment = 'EEE' OR Department = 'CSE'(Student)
- σDistrict ≠ 'Dhaka'(Student)
🔹 Key Properties
- Selection is a filtering operation — it does not alter columns, only filters rows.
- The output relation has the same attributes as the input relation.
- It can be combined with other operations like projection and join for complex queries.
✅ Summary
| Feature | Description |
|---|---|
| Operator | σ (Sigma) |
| Purpose | Selects tuples that satisfy a condition |
| Input | One relation |
| Output | Subset of rows of the same relation |
| SQL Equivalent | SELECT * FROM table WHERE condition; |
relational algebra selection operation, dbms relational algebra, sigma operator example, selection operation in dbms, student table example bangladesh, relational algebra tutorial, dbms class notes
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন