Jump to content

Projection (relational algebra)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Joseph Dwayne (talk | contribs) at 19:49, 18 September 2005 (creation; export from Relational algebra). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

In relational algebra, a projection is a unary operation written as where is a set of attribute names. The result of such projection is defined as the set that is obtained when all tuples in are restricted to the set . For an example, consider the following two tables which are the relation and its projection on the attributes and :

Name Age Weight
Harry 34 80
Sally 28 64
George 29 70
Helena 54 54
Peter 34 80
Age Weight
34 80
28 64
29 70
54 54

Note that Harry and Peter have the same age and weight, but since the result is a relation, and therefore a set, this combination only appears once in the result.

More formally the semantics of the projection is defined as follows:

where is the restriction of the tuple to the set so that

The result of a projection is only defined if is a subset of the header of .

In SQL, projections are done by using the SELECT statement.