Discrete Mathematics for Computer Science

(Romina) #1
Relational Databases: An Introduction 205

Relational databases have standard operations that act on relations. A request to extract
data from the database is called a query. Queries use standard operations to create their
output. The standard set of operations used is called the relational algebra. Three of the
operations of the relational algebra are described in the examples that follow.

First Operation: Selection
Given a relation such as Registration, some users may be interested in only some of the
values of an attribute. As an example, for an attribute such as Department, and a set of
possible values for that attribute, such as {Mathematics, Computer Science}, form a new
relation by selecting only the tuples with a value of Department that is in {Mathematics,
Computer Science).
Table 3.14 repeats the relation Registration so that you can easily compare this relation
to the one that will be generated by this operation.

Table 3.14 Registration Relation

Registration
Student Department Course Section
John von Neumann English 101 3
Emmy Noether English 101 3
Herman Hollerith English 101 3
George Boole English 101 4
Ren6 Descartes English 101 4
Winston Churchill English 101 4
John von Neumann English 103 1
Emmy Noether English 103 1
George Boole Mathematics 101 1
Winston Churchill Mathematics 101 1
Ren6 Descartes Computer Science 103 3
Herman Hollerith Computer Science 103 3

The result of this selection operation is the relation R', which is shown in Table 3.15.

Table 3.15 R' Relation

Student Department Course Section
George Boole Mathematics 101 1
Winston Churchill Mathematics 101 1
Rend Descartes Computer Science 103 3
Herman Hollerith Computer Science 103 3

Suppose a user wants to make a selection query of a database. A selection query returns
a table with just the tuples that satisfy some condition, like students taking mathematics
courses. The database contains relations R 1 , R 2 ..... R, To specify a selection query, the
user inputs three things: the name of the relation from which the selection is to be made

Free download pdf