3 ms·
I only had a quick look, is it a computer-friendly offshoot of relational algebra[1], the actual mathematical model for relational databases, as an actual query
by anyfoo 6y ago
I only had a quick look, is it a computer-friendly offshoot of relational algebra[1], the actual mathematical model for relational databases, as an actual query language?
[1]https://en.wikipedia.org/wiki/Relational_algebra https://en.wikipedia.org/wiki/Relational_algebra
- kd5bjo 6y agoRelational calculus is another mathematical model that is dual to relational algebra: if you have one representation you can always get the other. Relational algebra describes a fairly direct set of manipulations of database rows that can be implemented efficiently. Relational calculus operations are more abstract, but have useful identity transformations you can use to optimize query plans. So, when you ask a database system to perform a query, you ask it in relational algebra terms because they’re easy to understand. It then transforms your query into a relational calculus-like form to shuffle things around, and then back to a different, but equivalent, algebraic form to actually execute.
- anyfoo 6y agoThank you, that makes perfect sense.
- garmaine 6y agoRelational algebra is functional programming: you map-reduce your way to a solution set. Relational calculus is logical programming: you specify what the solution looks like and the query engine figures out the sequence of operations to find a solution.
- anyfoo 6y agoA useful analogy indeed, thanks.
- garmaine 6y agoIt goes a bit deeper than an analogy, but regardless I’m glad it helped! EDIT: To explain, the relational algebra IS a map-reduce functional programming language. The relational calculus IS a logical programming language. They just use tuples and sets instead of the more familiar lists and strings of LISP, Forth, Prolog, etc. And the sibling comment further up is right to point out that there are mechanical transformations to turn one into the other, just like there are automatic ways to compile Prolog into LISP (and vice-versa, though that is rarely done).