Wikipedia

Relational calculus

Also found in: Dictionary, Encyclopedia.

The Relational calculus consists of two calculi, the tuple relational calculus and the domain relational calculus, that are part of the relational model for databases and provide a declarative way to specify database queries.

The relational calculus is similar to the relational algebra, 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 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.

A relational algebra expression might prescribe the following steps to retrieve the phone numbers and names of book stores that supply Some Sample Book:

  1. Join book stores and titles over the BookstoreID.
  2. Restrict the result of that join to tuples for the book Some Sample Book.
  3. 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.

The relational algebra and the relational calculus are logically equivalent: for any algebraic expression, there is an equivalent expression in the calculus, and vice versa. This result is known as Codd's theorem.

The raison d'être of the relational calculus is the formalization of query optimization. Query optimization 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.

References

  • Date, Christopher J. (2004). An Introduction to Database Systems (8th ed.). Addison Wesley. ISBN 0-321-19784-4.
This article is copied from an article on Wikipedia® - the free encyclopedia created and edited by its online user community. The text was not checked or edited by anyone on our staff. Although the vast majority of Wikipedia® encyclopedia articles provide accurate and timely information, please do not assume the accuracy of any particular article. This article is distributed under the terms of GNU Free Documentation License.

Copyright © 2003-2025 Farlex, Inc Disclaimer
All content on this website, including dictionary, thesaurus, literature, geography, and other reference data is for informational purposes only. This information should not be considered complete, up to date, and is not intended to be used in place of a visit, consultation, or advice of a legal, medical, or any other professional.