Projection (relational algebra)
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 obtained when the components of the tuple are restricted to the set – it discards (or excludes) the other attributes.
In practical terms, it can be roughly thought of as picking a sub-set of all available columns. For example, if the attributes are (name, age), then projection of the relation {(Alice, 5), (Bob, 8)} onto attribute list (age) yields {5,8} – we have discarded the names, and only know what ages are present.
In addition, projection can be used to modify an attribute's value: if relation R has attributes a, b, and c, and b is a number, then
will return a relation nearly the same as R, but with all values for 'b' shrunk by half.
Related concepts
The closely related concept in set theory (see: projection (set theory)) differs from that of relational algebra in that, in set theory, one projects onto ordered components, not onto attributes. For instance, projecting onto the second component yields 7.