Projection (relational algebra)

Projection (relational algebra)

Introduction

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.

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.

Related concepts

In set theory, projection is closely related – there one projects onto a single ordered component or several 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:

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.

See also

* Projection (set theory)


Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • Relational algebra — Not to be confused with Relation algebra. Relational algebra, an offshoot of first order logic (and of algebra of sets), deals with a set of finitary relations (see also relation (database)) that is closed under certain operators. These operators …   Wikipedia

  • Projection — Contents 1 Chemistry 2 Mathematics 3 Other 4 See also …   Wikipedia

  • Projection (set theory) — In set theory, a projection is one of two closely related types of functions or operations, namely:* A set theoretic operation typified by the j th projection map, written mathrm{proj} {j}!, that takes an element vec{x} = (x 1, ldots, x j, ldots …   Wikipedia

  • Relational database — A visual diagram showing the relationship between the two tables, as indicated by the arrow A relational database matches data by using common characteristics found within the data set. The resulting groups of data uses the relational model (a… …   Wikipedia

  • Relational model — The relational model for database management is a database model based on first order predicate logic, first formulated and proposed in 1969 by Edgar Codd. [ Derivability, Redundancy, and Consistency of Relations Stored in Large Data Banks , E.F …   Wikipedia

  • Relational Database Management System — Eine relationale Datenbank dient zur elektronischen Datenverwaltung in Computersystemen und beruht auf dem relationalen Datenbankmodell. Dieses wurde 1970 von Edgar F. Codd erstmals vorgeschlagen und ist bis heute, trotz einiger Kritikpunkte, ein …   Deutsch Wikipedia

  • Relational Database Management Systems — Eine relationale Datenbank dient zur elektronischen Datenverwaltung in Computersystemen und beruht auf dem relationalen Datenbankmodell. Dieses wurde 1970 von Edgar F. Codd erstmals vorgeschlagen und ist bis heute, trotz einiger Kritikpunkte, ein …   Deutsch Wikipedia

  • Information algebra — Classical information theory goes back to Claude Shannon. It is a theory of information transmission, looking at communication and storage. However, it has not been considered so far that information comes from different sources and that it is… …   Wikipedia

  • Rete — эффективный алгоритм сопоставления с образцом для продукционных систем, экспертных систем и баз знаний , созданный Чарльзом Форги из Университета Карнеги Меллона. Впервые был описан в рабочем документе 1974 года, затем в докторской диссертации… …   Википедия

  • Алгоритм Rete — Rete[1]  эффективный алгоритм сопоставления с образцом для продукционных систем, экспертных систем и баз знаний, созданный Чарльзом Форги из Университета Карнеги Меллона. Впервые был описан в рабочем документе 1974 года, затем в докторской… …   Википедия

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”