from Hacker News

Introduction to Datalog

by x775 on 3/18/19, 4:55 PM with 38 comments

  • by JoelMcCracken on 3/18/19, 7:00 PM

    Can anyone recommend any implementation of Datalog (+ negation) that is not datomic?

    I haven't tried datascript, which appears to support negation. Maybe I will try that if/when I revisit this interest someday.

  • by sdbrady on 3/18/19, 6:32 PM

    Thanks for sharing. There is one very significant conceptual error early on, however, and it is captured first in this statement: "The :- means if and only if, or iff". `:-` means if - or more precisely represents material conditional - where the consequent is on the left and the antecedent is on the right. iff is logical biconditional.
  • by hombre_fatal on 3/18/19, 5:48 PM

    Pretty cool deep-dive on Datalog.

    The interactive tutorials on http://www.learndatalogtoday.org (Datomic's dialect) quickly sold me on the idea.

    Though coming from Datomic, I'm curious how much of my knowledge is Datomic-specific rather than how you'd generally approach a database queryable with Datalog. For example, do you need four indexes like Datomic (https://docs.datomic.com/on-prem/indexes.html) to make Datalog queries fast?

  • by nmadden on 3/18/19, 7:28 PM

    Great post! Still working through it, but there is a slight error in the nested diagram at the start. Relational algebra has set difference, which is akin to negation-as-failure, but it lacks recursion. So the positive Datalog and RA circles should overlap without either containing the other. See http://www.lifl.fr/%7Ekuttler/elfe/biblio/datalog-overview-g...
  • by burakemir on 3/18/19, 8:02 PM

    Nice post. Still, I find the most accessible article describing datalog is "What you Always Wanted to Know About Datalog (And Never Dared to Ask)." by Ceri, Gottlob, Tanca (1989)
  • by radomir_cernoch on 3/18/19, 6:27 PM

    > The :- means if and only if, or iff.

    Is it really the case?

      Human("Socrates").
      Animal("Turtle").
      Mortal(x) :- Human(x).
      Mortal(x) :- Animal(x).
    
    Suppose :- means iff. Turtle is Mortal (lines 2+4, implication to the left). Because Turtle is Mortal, it must be a Human (line 3, implication to the right).

    Is it really valid according to Datalog semantics?

  • by bobjordan on 3/19/19, 4:21 AM

    Sharing an interesting implementation in python which I stumbled upon yesterday. Repo: https://github.com/pcarbonn/pyDatalog Tutorial: https://sites.google.com/site/pydatalog/Online-datalog-tutor...
  • by ComNik on 3/18/19, 10:03 PM

    If model-theoretic semantics and the various ways to slice, dice, and extend Datalog are interesting to you, then almost any talk by Peter Alvaro might be as well.

    In particular: https://www.youtube.com/watch?v=R2Aa4PivG0g

  • by fspeech on 3/18/19, 5:32 PM

    Can you specify symmetric and transitive closure in Datalog?
  • by slifin on 3/18/19, 5:54 PM

    Thank you, bookmarking this for later