HOME

TheInfoList



OR:

The relational calculus consists of two calculi, the
tuple relational calculus Tuple calculus is a calculus that was created and introduced by Edgar F. Codd as part of the relational model, in order to provide a declarative database-query language for data manipulation in this data model. It formed the inspiration for the d ...
and the
domain relational calculus In computer science, domain relational calculus (DRC) is a calculus that was introduced by Michel Lacroix and Alain Pirotte as a declarative database query language for the relational data model.Michel Lacroix, Alain PirotteDomain-Oriented Relatio ...
, that are part of the relational model for databases and provide a declarative way to specify database queries. The raison d'ĂȘtre of the relational calculus is the formalization of
query optimization Query optimization is a feature of many relational database management systems and other databases such as NoSQL and graph databases. The query optimizer attempts to determine the most efficient way to execute a given query by considering the p ...
, which is finding more efficient manners to execute the same query. The relational calculus is similar to the
relational algebra In database theory, relational algebra is a theory that uses algebraic structures with a well-founded semantics for modeling data, and defining queries on it. The theory was introduced by Edgar F. Codd. The main application of relational algebr ...
, which is also part of the relational model: While the relational calculus is meant as a declarative language which prescribes no execution order on the subexpressions of a relational calculus expression, the
relational algebra In database theory, relational algebra is a theory that uses algebraic structures with a well-founded semantics for modeling data, and defining queries on it. The theory was introduced by Edgar F. Codd. The main application of relational algebr ...
is meant as an imperative language: the sub-expressions of a relational algebraic expressions are meant to be executed from left-to-right and inside-out following their nesting. Per
Codd's theorem Codd's theorem states that relational algebra and the domain-independent relational calculus queries, two well-known foundational query languages for the relational model, are precisely equivalent in expressive power. That is, a database query can ...
, the relational algebra and the domain-independent relational calculus are
logically equivalent Logic is the study of correct reasoning. It includes both formal and informal logic. Formal logic is the science of deductively valid inferences or of logical truths. It is a formal science investigating how conclusions follow from premise ...
.


Example

A
relational algebra In database theory, relational algebra is a theory that uses algebraic structures with a well-founded semantics for modeling data, and defining queries on it. The theory was introduced by Edgar F. Codd. The main application of relational algebr ...
expression might prescribe the following steps to retrieve the phone numbers and names of book stores that supply ''Some Sample Book'': # Join book stores and titles over the BookstoreID. # Restrict the result of that join to tuples for the book ''Some Sample Book''. # Project the result of that restriction over StoreName and StorePhone. A relational calculus expression would formulate this query in the following descriptive or declarative manner: :Get StoreName and StorePhone for book stores such that there exists a title BK with the same BookstoreID value and with a BookTitle value of ''Some Sample Book''.


Mathematical properties

The relational algebra and the domain-independent relational calculus are
logically equivalent Logic is the study of correct reasoning. It includes both formal and informal logic. Formal logic is the science of deductively valid inferences or of logical truths. It is a formal science investigating how conclusions follow from premise ...
: for any algebraic expression, there is an equivalent expression in the calculus, and vice versa. This result is known as
Codd's theorem Codd's theorem states that relational algebra and the domain-independent relational calculus queries, two well-known foundational query languages for the relational model, are precisely equivalent in expressive power. That is, a database query can ...
.


Purpose

The raison d'ĂȘtre of the relational calculus is the formalization of
query optimization Query optimization is a feature of many relational database management systems and other databases such as NoSQL and graph databases. The query optimizer attempts to determine the most efficient way to execute a given query by considering the p ...
.
Query optimization Query optimization is a feature of many relational database management systems and other databases such as NoSQL and graph databases. The query optimizer attempts to determine the most efficient way to execute a given query by considering the p ...
consists in determining from a query the most efficient manner (or manners) to execute it. Query optimization can be formalized as translating a relational calculus expression delivering an answer A into efficient relational algebraic expressions delivering the same answer A.


See also

*
Calculus of relations In mathematical logic, algebraic logic is the reasoning obtained by manipulating equations with free variables. What is now usually called classical algebraic logic focuses on the identification and algebraic description of models appropriate for ...


References

* Logical calculi Relational model {{database-stub