206 CHAPTER 3 Relations
(that is, some Ri), the (name of the) attribute on which the selection is to be made, and a
finite set of possible values for that attribute. Then, the database system outputs all tuples
in that relation with a value for the attribute that is in that finite set.
There is also a second form that we shall use in the exercises: The user may input the
name of the relation, the names of two attributes, and = or <. If the user inputs Teaching-
Assignments, Section, Course, and <, then the user is asking for all scheduled courses
(for which teachers have been assigned) where the section number is less than the course
number.
What we have given here is a much more limited than the standard database definition
of selection. We have adopted this definition to keep the exposition simple.
Second Operation: Projection
For any table in a relational database, it often happens that a query is only interested in one
attribute. For example, in the relation R' in Table 3.14, suppose that you want to know the
names of the students. The only attribute of interest is Student. The attributes Department,
Course, and Section all may be important in other contexts, but for now, only the Student
entries are needed. The operation that reduces a relation to a new relation consisting of
some of the attributes and the entries for those attributes is called projection.
The second operation, or projection, is now used to find a relation that consists of
some of the attributes of an existing relation. A relation, such as Registration, and a subset
of its attributes, such as {Student, Department, I form the projection Rt of the relation onto
those attributes as follows: First, delete the attributes not in {Student, Department} from
each tuple of the relation Registration. The resulting relation Rt is shown in Table 3.16.
Table 3.16 Rt Relation with Duplicates
Rt
Student Department
John von Neumann English ÷-
Emmy Noether English
Herman Hollerith English
George Boole English
Ren6 Descartes English
Winston Churchill English
John von Neumann English +-
Emmy Noether English
George Boole Mathematics
Winston Churchill Mathematics
Ren6 Descartes Computer Science
Herman Hollerith Computer Science
In Table 3.16, you see that the tuples (John von Neumann, English) and (Emmy
Noether, English) occur twice. Since a relation is a set, it makes no sense to say twice
that a tuple is an element of a set. So, the final step in forming a projection is to eliminate
duplicate entries from the table Rt to form the relation Registration' shown in Table 3.17.
The projection of Registration tells which students are taking classes in which depart-
ments.