# Projection

**DOI:**https://doi.org/10.1007/978-1-4899-7993-3_1258-2

## Synonyms

## Definition

Given a relation instance *R* over set of attributes *U*, and given a subset *X* of *U*, the projection of *R* on *X* – denoted by π_{ X }(*R*) – is defined as a relation over set of attributes *X* whose tuples are the restriction of tuples of *R* to attributes *X*. That is, *t* ∈ π_{ X }(*R*) if and only if *t* = *t*′(*X*) for some tuple *t*′ of *R* (here *t*′(*X*) denotes the restriction of *t*′ to attributes *X*).

## Key Points

The projection is one of the basic operators of the relational algebra. It operates by “restricting” the input relation to some of its columns.

The arity of the output relation is bounded by the arity of the input relation. Moreover the number of tuples in π_{ X }(*R*) is bounded by the number of tuples in *R*. In particular, the size of π_{ X }(*R*) can be strictly smaller than the size of *R* since different tuples of *R* may have the same values on attributes *X*.

As an example, consider a relation *Goods* over attributes (*code, price, quantity*), containing tuples {(001, 5.00, 10), (002, 5.00, 10), (003, 25.00, 3)}. Then π_{ price,quantity } (*Goods*) is a relation over attributes (*price, quantity*) with tuples {(5.00, 10), (25.00, 3)}.

In the case that attribute names are not present in the relation schema, the projection is specified by an expression of the form π*i* _{1},...,*i* _{ n }(*R*). Here *i* _{1},...,*i* _{ n } is a sequence of positive integers – where each *i* _{ j } is bounded by the arity of *R* – identifying attributes of *R*. The output is a relation of arity *n* with tuples (*t*(*i* _{1}),...,*t*(*i* _{ n })), for each tuple *t* in *R*. In this case the arity *n* of the output relation can be possibly larger than the arity of *R*, since integers *i* _{1},…,*i* _{ n } need not be distinct.