4 ms·
So for someone who is familiar with it, why hasn't Datalog supplanted SQL for relational querying? What's its limitation?
by BoiledCabbage 8y ago
So for someone who is familiar with it, why hasn't Datalog supplanted SQL for relational querying? What's its limitation?
- bowyakka 8y agoOn the continum of relational algebra to logic programming catalog is somewhere in the middle. It is better at handling recursive queries, and logical inference than SQL. On the flip side SQL can be better at more set style operations (for instance windowing functions are painful in datalog). It is different tooling, essentially it comes down to do you want to extract answers from your data with varying relational algebra but holding the logic the same (SQL), or keeping the relational algebra the same but varying the logic (datalog).
- aargh_aargh 8y agoCould you please explain what you mean by "varying relational algebra/logic"? Didn't understand that at all. I only know SQL.
- alecco 8y agoLack of standards and lack of a killer engine implementing it. Also people don't like to switch and SQL does a good enough job for most cases and recently it added a lot of fancy features like windowing functions.
- tannhaeuser 8y agoProlog, of which Datalog is a syntactical subset, is an ISO standard since 1995.
- mathetic 8y agoThat doesn't help at all because although Datalog is a syntactic fragment, its dynamic semantics are very different, so the operations defined in Prolog standard are suggestive at best and completely nonsensical at worst. For example, the program `p(X) :- p(X)` with query `?- p(X)` is an infinite loop in Prolog but in Datalog it terminates trivially and is equal to the empty set of facts for `p` in the absence any other facts.
- mathetic 8y agoI think it's more cultural than anything else. SQL, despite being declarative itself, has a more imperative feel to it for some people (recursion being at the fringes of its standard) and people seem to believe more declarative means slower and more difficult to comprehend. The former is true only due to the implementation effort that went into SQL engines and the latter is plain false. It probably doesn't help that the standard presentation of Datalog looks very much like Prolog, which most people think is an esoteric and failed programming language. As for its limitations, it's disciplined in a number of ways, but those are features rather than shortcomings. So you can see in the post that it employs syntactic restrictions to ensure domain independence, it doesn't allow function symbols to have termination. It requires predicates that are not purely logical (extralogical) to satisfy certain conditions for safe execution. These make sure that your queries are well-behaved even before you start running the query. There is research on relaxing these restrictions (cough my work cough) without compromising on the nice properties that come along with it. The nice thing is of course that if you want to do the same for SQL you start with pandora's box open and try to contain the chaos inside again, while with Datalog you're carefully trying to make the best out of it without unleashing madness. The latter is a much nicer foundation.