#jsDisabledContent { display:none; } My Account | Register | Help

Projection (relational algebra)

Article Id: WHEBN0002702833
Reproduction Date:

 Title: Projection (relational algebra) Author: World Heritage Encyclopedia Language: English Subject: Collection: Relational Algebra Publisher: World Heritage Encyclopedia Publication Date:

Projection (relational algebra)

In relational algebra, a projection is a unary operation written as \Pi_{a_1, ...,a_n}( R ) where a_1,...,a_n is a set of attribute names. The result of such projection is defined as the set obtained when the components of the tuple R are restricted to the set \{a_1,...,a_n\} – it discards (or excludes) the other attributes.[1]

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 \Pi_{a,\ b * 0.5,\ c}( R ) will return a relation nearly the same as R, but with all values for 'b' shrunk by half.[2]

Contents

• Related concepts 1
• Example 2
• References 4

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 (3,7) 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.

Example

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

Person \Pi_{Age,Weight}(Person)
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:

\Pi_{a_1, ...,a_n}( R ) = \{ \ t[a_1,...,a_n] : \ t \in R \ \}

where t[a_1,...,a_n] is the restriction of the tuple t to the set \{a_1,...,a_n\} so that

t[a_1,...,a_n] = \{ \ ( a', v ) \ | \ ( a', v ) \in t, \ a' \in a_1,...,a_n \ \}

The result of a projection \Pi_{a_1, ...,a_n}( R ) is defined only if \{a_1,...,a_n\} is a subset of the header of R.

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.

References

1. ^ "Relational Algebra". cs.rochester.edu. Retrieved 2014-07-28.
2. ^ http://www.csee.umbc.edu/~pmundur/courses/CMSC661-02/rel-alg.pdf See Problem 3.8.B on page 3
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.

Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.