Relational calculus
The relational calculus consists of two calculi, the tuple relational calculus and the domain relational calculus, that is part of the relational model for databases and provide a declarative way to specify database queries. The raison d'être of relational calculus is the formalization of query optimization, which is finding more efficient manners to execute the same query in a database. 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 that prescribes no execution order on the subexpressions of a relational calculus expression, the relational algebra is meant as an... Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.
The relational calculus consists of two calculi, the tuple relational calculus and the domain relational calculus, that is part of the relational model for databases and provide a declarative way to specify database queries. The raison d'être of relational calculus is the formalization of query optimization, which is finding more efficient manners to execute the same query in a database. 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 that 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 expression are meant to be executed from left-to-right and inside-out following their nesting. Per Codd's theorem, the relational algebra and the domain-independent relational calculus are logically equivalent. The query can be written as: \pi_{StoreName, StorePhone}(\sigma_{BookTitle='Some Sample Book'}(B\bowtie_{B.BookstoreID=T.BookstoreID} T)) A more explicit equivalent form is: \pi_{StoreName, StorePhone}(B\bowtie_{B.BookstoreID=T.BookstoreID} (\sigma_{BookTitle='Some Sample Book'}(T))) The second form is often preferred because it pushes the selection down before the join. \{\langle b.StoreName, b.StorePhone \rangle \mid B(b) \wedge \exists t : (T(t) \wedge b.BookstoreID=t.BookstoreID \wedge t.BookTitle='Some Sample Book')\} This says: return the store name and phone number of every bookstore b for which there exists a title tuple t with matching BookstoreID and the book title equal to "Some Sample Book". B\bowtie_{B.BookstoreID=T.BookstoreID} T means exactly the set of pairs (b, t) such that: B(b) \wedge T(t) \wedge b.BookstoreID=t.BookstoreID Then applying selection: \sigma_{T.BookTitle='Some Sample Book'}(\cdot) adds: t.BookTitle='Some Sample Book' So the algebraic expression becomes the set of all joined pairs satisfying: B(b) \wedge T(t) \wedge b.BookstoreID=t.BookstoreID \wedge t.BookTitle='Some Sample Book' \{\langle b.StoreName, b.StorePhone\rangle \mid \exists t : (B(b) \wedge T(t) \wedge b.BookstoreID=t.BookstoreID \wedge t.BookTitle='Some Sample Book')\} which is exactly the calculus expression. \sigma_{BookTitle='Some Sample Book'}(B\bowtie T) \equiv B\bowtie (\sigma_{BookTitle='Some Sample Book'}(T)) This is the relational algebra selection-pushdown law. It preserves meaning and often improves efficiency. \pi_{StoreName, StorePhone}(\sigma_{BookTitle='Some Sample Book'}(B\bowtie T)) denotes the same set as \{\langle b.StoreName, b.StorePhone \rangle \mid B(b) \wedge \exists t : (T(t) \wedge b.BookstoreID=t.BookstoreID \wedge t.BookTitle='Some Sample Book')\}
Cite this
"Relational calculus". 1788205234. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1372464789 JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy