5.5 SELECT Phrases
Queries must be written based on the names and headings of the tabular vari-
ables and not on the tables that represent their values at any given moment.
This is similar to writing programs. A program should work for all legal inputs
and not just the ones on which it was tested. In both cases, it is important to
focus on the abstract structure and not on specific examples. The way we write
SQL constructs must be directed only by the logic of the query and not by the
content of a particular database instance. Just because the query generated the
right answer for a particular instance of the database does not mean that it is
correct.
The main retrieval construction is the select phrase. Consider a query that
we solved previously using relational algebra. Recall that in Example 4.1.25 we
found the names of all instructors who have taught any student who lives in
Brookline. The solution involved using product, selection, and projection: