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.[1]

In practical terms, it can be roughly thought of as picking a subset 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.[2]

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.

Projection is relational algebra's counterpart of existential quantification in predicate logic. The attributes not included correspond to existentially quantified variables in the predicate whose extension the operand relation represents. The example below illustrates this point.

Because of the correspondence with existential quantification, some authorities prefer to define projection in terms of the excluded attributes. In a computer language it is of course possible to provide notations for both, and that was done in ISBL and several languages that have taken their cue from ISBL.

A nearly identical concept occurs in the category of monoids, called a string projection, which consists of removing all of the letters in the string that do not belong to a given alphabet.

When implemented in SQL standard the "default projection" returns a multiset instead a set, and the ? projection is obtained by the adiction of the DISTINCT keyword to eliminates duplicate data.


For an example, consider the relations depicted in the following two tables which are the relation and its projection on (some say "over") the attributes and :

Name Age Weight
Harry 34 180
Sally 28 164
George 29 170
Helena 54 154
Peter 34 180
Age Weight
34 180
28 164
29 170
54 154

Suppose the predicate of Person is "Name is age years old and weighs weight." Then the given projection represents the predicate, "There exists Name such that Name is age years old and weighs weight."

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 projection are defined as follows:

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

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

It is interesting to note that projection over no attributes at all is possible, yielding a relation of degree zero. In this case the cardinality of the result is zero if the operand is empty, otherwise one. The two relations of degree zero are the only ones that cannot be depicted as tables.

See also


  1. ^ "Relational Algebra". Retrieved . 
  2. ^ See Problem 3.8.B on page 3

  This article uses material from the Wikipedia page available here. It is released under the Creative Commons Attribution-Share-Alike License 3.0.



Connect with defaultLogic
What We've Done
Led Digital Marketing Efforts of Top 500 e-Retailers.
Worked with Top Brands at Leading Agencies.
Successfully Managed Over $50 million in Digital Ad Spend.
Developed Strategies and Processes that Enabled Brands to Grow During an Economic Downturn.
Taught Advanced Internet Marketing Strategies at the graduate level.

Manage research, learning and skills at defaultLogic. Create an account using LinkedIn or facebook to manage and organize your Digital Marketing and Technology knowledge. defaultLogic works like a shopping cart for information -- helping you to save, discuss and share.

  Contact Us