Worked Examples · Example 9.2
Q.The following query retrieves the name and date of birth of the student with roll number 1 from the STUDENT table.
CBSENCERTSubjective· 2mImportance★★★★★
3% · 3/95 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →The query is a selection (WHERE RollNumber = 1) followed by a projection (SELECT SName, SDateofBirth). Run against the STUDENT table of Table 9.7, it returns exactly one row: Atharv Ahuja, 2003-05-15.
Concept: Projection and Selection
Every SELECT statement combines two relational-algebra operations:
- Projection (SELECT clause) — chooses which columns appear in the result.
- Selection (WHERE clause) — chooses which rows appear in the result.
The query
SELECT SName, SDateofBirth
FROM STUDENT
WHERE RollNumber = 1;
FROM STUDENT— the table to query.WHERE RollNumber = 1— the selection: keep only the row(s) whereRollNumberequals 1. In relational algebra: σ<sub>RollNumber=1</sub>(STUDENT).SELECT SName, SDateofBirth— the projection: of the row(s) that survive the selection, keep only these two columns.
Running it against the real STUDENT table
This chapter populates the STUDENT table with the six rows of Table 9.7:
| RollNumber | SName | SDateofBirth | GUID |
|---|---|---|---|
| 1 | Atharv Ahuja | 2003-05-15 | 444444444444 |
| 2 | Daizy Bhutia | 2002-02-28 | 111111111111 |
| 3 | Taleem Shah | 2002-02-28 | NULL |
| 4 | John Dsouza | 2003-08-18 | 333333333333 |
| 5 | Ali Shah | 2003-07-05 | 101010101010 |
| 6 | Manika P. | 2002-03-10 | 466444444666 |
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.