0
0
DBMS Theoryknowledge~10 mins

Selection operation implementation in DBMS Theory - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Selection operation implementation
Start with a Relation (Table)
Apply Selection Condition
Check each Tuple
Include Tuple
Form Result Relation
End
The selection operation scans each row of a table and keeps only those rows that satisfy a given condition, forming a new table as the result.
Execution Sample
DBMS Theory
SELECT * FROM Employees WHERE Age > 30;
This query selects all rows from the Employees table where the Age column is greater than 30.
Analysis Table
StepTuple (Employee)Condition (Age > 30)Result Action
1{ID: 1, Name: 'Alice', Age: 28}28 > 30? FalseDiscard
2{ID: 2, Name: 'Bob', Age: 35}35 > 30? TrueInclude
3{ID: 3, Name: 'Charlie', Age: 30}30 > 30? FalseDiscard
4{ID: 4, Name: 'Diana', Age: 40}40 > 30? TrueInclude
5{ID: 5, Name: 'Evan', Age: 25}25 > 30? FalseDiscard
6All tuples checked-Selection complete
💡 All tuples have been checked; selection condition applied to each tuple.
State Tracker
VariableStartAfter 1After 2After 3After 4After 5Final
Current TupleNone{ID:1, Age:28}{ID:2, Age:35}{ID:3, Age:30}{ID:4, Age:40}{ID:5, Age:25}None
Result RelationEmptyEmpty[{ID:2, Age:35}][{ID:2, Age:35}][{ID:2, Age:35}, {ID:4, Age:40}][{ID:2, Age:35}, {ID:4, Age:40}][{ID:2, Age:35}, {ID:4, Age:40}]
Key Insights - 3 Insights
Why is the tuple with Age 30 not included even though it equals 30?
Because the condition is Age > 30, which means strictly greater than 30. The tuple with Age 30 does not satisfy this, as shown in step 3 of the execution_table.
What happens to tuples that do not meet the condition?
They are discarded and not included in the result relation, as seen in steps 1, 3, and 5 where the action is 'Discard'.
When does the selection operation stop checking tuples?
It stops after all tuples in the original relation have been checked, indicated by step 6 in the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the Result Action for the tuple with Age 40?
AInclude
BDiscard
CNot checked
DError
💡 Hint
Refer to step 4 in the execution_table where Age is 40.
At which step does the condition Age > 30 become false for the first time?
AStep 2
BStep 3
CStep 1
DStep 5
💡 Hint
Check the Condition column in execution_table starting from step 1.
If the condition changed to Age >= 30, which tuple's Result Action would change?
ATuple with Age 28
BTuple with Age 30
CTuple with Age 25
DTuple with Age 40
💡 Hint
Look at step 3 in execution_table where Age is exactly 30.
Concept Snapshot
Selection Operation:
- Filters rows from a table based on a condition.
- Syntax example: SELECT * FROM Table WHERE condition;
- Checks each tuple; includes only those satisfying the condition.
- Result is a new relation with selected tuples.
- Stops after all tuples are checked.
Full Transcript
The selection operation in a database scans each row of a table and applies a condition to decide if the row should be included in the result. For example, selecting employees older than 30 means checking each employee's age and including only those with age greater than 30. The process continues until all rows are checked, forming a new table with only the matching rows. Tuples not meeting the condition are discarded. This operation is fundamental for filtering data in queries.