# Relational algebra

**joinrelational logicθ''-joincomplex joinsEquijoinjoin operation in relational algebrajoinsrelationalrelational joinrelational patterns**

Relational algebra, first created by Edgar F. Codd while at IBM, is a family of algebras with a well-founded semantics used for modelling the data stored in relational databases, and defining queries on it.wikipedia

112 Related Articles

### SQL

**Structured Query LanguageSQL DatabasesWikibook SQL**

The main application of relational algebra is providing a theoretical foundation for relational databases, particularly query languages for such databases, chief among which is SQL. Note: when implemented in SQL standard the "default projection" returns a multiset instead of a set, and the

Originally based upon relational algebra and tuple relational calculus, SQL consists of many types of statements, which may be informally classed as sublanguages, commonly: a data query language (DQL), a data definition language (DDL), a data control language (DCL), and a data manipulation language (DML).

### Selection (relational algebra)

**selectionselections**

Five primitive operators of Codd's algebra are the selection, the projection, the Cartesian product (also called the cross product or cross join), the set union, and the set difference. A generalized selection is a unary operation written as where is a propositional formula that consists of atoms as allowed in the normal selection and the logical operators ðŸ‡¦ðŸ‡© (and), (or) and (negation).

In relational algebra, a selection (sometimes called a restriction in reference to E.F. Codd's 1970 paper and not, contrary to a popular belief, to avoid confusion with SQL's use of SELECT, since Codd's article predates the existence of SQL) is a unary operation that denotes a subset of a relation.

### Projection (relational algebra)

**projectionprojectionsproject**

Five primitive operators of Codd's algebra are the selection, the projection, the Cartesian product (also called the cross product or cross join), the set union, and the set difference.

In relational algebra, a projection is a unary operation written as where a_1,...,a_n is a set of attribute names.

### Relational model

**relationalrelational data modelrelationships**

Relational algebra received little attention outside of pure mathematics until the publication of E.F. Codd's relational model of data in 1970.

Data are operated upon by means of a relational calculus or relational algebra, these being equivalent in expressive power.

### Edgar F. Codd

**E. F. CoddCoddE.F. Codd**

Relational algebra received little attention outside of pure mathematics until the publication of E.F. Codd's relational model of data in 1970. Relational algebra, first created by Edgar F. Codd while at IBM, is a family of algebras with a well-founded semantics used for modelling the data stored in relational databases, and defining queries on it.

Codd's theorem, a result proven in his seminal work on the relational model, equates the expressive power of relational algebra and relational calculus (both of which, lacking recursion, are strictly less powerful than first-order logic).

### Select (SQL)

**SELECT keywordSELECTs**

projection is obtained by the addition of the keyword to eliminate duplicate data.

This is similar to a projection in Relational algebra, except that in the general case, the result may contain duplicate rows.

### Tuple

**5-tuplen''-tupletuples**

The result of such projection is defined as the set that is obtained when all tuples in R are restricted to the set.

Tuples also occur in relational algebra; when programming the semantic web with the Resource Description Framework (RDF); in linguistics; and in philosophy.

### Relation (database)

**relationrelation schemarelations**

For set union and set difference, the two relations involved must be union-compatibleâ€”that is, the two relations must have the same set of attributes.

A view can be defined by an expression using the operators of the relational algebra or the relational calculus.

### Aggregate function

**aggregationsdecomposable aggregation functionAggregate**

There are five aggregate functions that are included with most relational database systems.

Aggregate functions occur commonly in numerous programming languages, in spreadsheets, and in relational algebra.

### Null (SQL)

**NULL NULLs**

The operators defined in this section assume the existence of a null value, Ï‰, which we do not define, to be used for the fill values; in practice this corresponds to the NULL in SQL.

In particular a table containing any nulls is not equal with a natural self-join of itself, meaning that whereas is true for any relation R in relational algebra, a SQL self-join will exclude all rows having a Null anywhere.

### Query optimization

**query optimizeroptimizationQuery processing**

Our primary goal is to transform expression trees into equivalent expression trees, where the average size of the relations yielded by subexpressions in the tree is smaller than it was before the optimization.

These consist of logical optimizationâ€”which generates a sequence of relational algebra to solve the queryâ€”and physical optimizationâ€”which is used to determine the means of carrying out each operation.

### Composition of relations

**compositionrelation compositioncomposition of binary relations**

This can also be used to define composition of relations.

Other forms of composition of relations, which apply to general n-place relations instead of binary relations, are found in the join operation of relational algebra.

### Pullback (category theory)

**pullbackfiber productpullbacks**

In category theory, the join is precisely the fiber product.

Equijoin in relational algebra

### Relational database

**relational databasesrelationaldatabase constraints**

The main application of relational algebra is providing a theoretical foundation for relational databases, particularly query languages for such databases, chief among which is SQL.

Queries made against the relational database, and the derived relvars in the database are expressed in a relational calculus or a relational algebra.

### Well-founded semantics

Relational algebra, first created by Edgar F. Codd while at IBM, is a family of algebras with a well-founded semantics used for modelling the data stored in relational databases, and defining queries on it.

### Query language

**querydatabase languagedatabase query language**

The main application of relational algebra is providing a theoretical foundation for relational databases, particularly query languages for such databases, chief among which is SQL.

### Cartesian product

**productÃ—Cartesian square**

Five primitive operators of Codd's algebra are the selection, the projection, the Cartesian product (also called the cross product or cross join), the set union, and the set difference. The relational algebra uses set union, set difference, and Cartesian product from set theory, but adds additional constraints to these operators.

### Union (set theory)

**unionset unionunions**

Five primitive operators of Codd's algebra are the selection, the projection, the Cartesian product (also called the cross product or cross join), the set union, and the set difference. The relational algebra uses set union, set difference, and Cartesian product from set theory, but adds additional constraints to these operators.

### Set theory

**axiomatic set theoryset-theoreticset**

The relational algebra uses set union, set difference, and Cartesian product from set theory, but adds additional constraints to these operators.

### Intersection (set theory)

**intersectionintersectionsset intersection**

Because set intersection is defined in terms of set union and set difference, the two relations involved in set intersection must also be union-compatible.

### Set (mathematics)

**setsetsmathematical set**

The result of such projection is defined as the set that is obtained when all tuples in R are restricted to the set. In addition, the Cartesian product is defined differently from the one in set theory in the sense that tuples are considered to be "shallow" for the purposes of the operation.

### Unary operation

**unaryunary operatormonadic**

A projection is a unary operation written as where is a set of attribute names. A generalized selection is a unary operation written as where is a propositional formula that consists of atoms as allowed in the normal selection and the logical operators ðŸ‡¦ðŸ‡© (and), (or) and (negation).

### Multiset

**multisetsbagmultiset coefficient**

Note: when implemented in SQL standard the "default projection" returns a multiset instead of a set, and the

### Propositional formula

**algebra of propositionsBooleanBoolean formulas**

A generalized selection is a unary operation written as where is a propositional formula that consists of atoms as allowed in the normal selection and the logical operators ðŸ‡¦ðŸ‡© (and), (or) and (negation).

### Atomic formula

**atomatomicatomic expressions**

A generalized selection is a unary operation written as where is a propositional formula that consists of atoms as allowed in the normal selection and the logical operators ðŸ‡¦ðŸ‡© (and), (or) and (negation).