Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For those interested in database query languages, it is worth knowing about Datalog, the query language behind Datomic, XTDB and Datahike: http://www.learndatalogtoday.org/

E.g. a parameterised aggregate query that retrieves the name and average rating of a film starring cast members whose names match the input names:

    [:find ?name (avg ?rating)
     :in $ [?name ...] [[?title ?rating]]
     :where
     [?p :person/name ?name]
     [?m :movie/cast ?p]
     [?m :movie/title ?title]]
To reveal the answer, click on tab labelled "3" and then "I give up!": http://www.learndatalogtoday.org/chapter/7


This is the Datomic/Clojure dialect of Datalog. I had an easier time learning a stand-alone datalog variant. I think compiling Datalog to SQL is an interesting idea.

I wrote a toy Datalog -> SQLite compiler: https://percival.jake.tl/

Other Datalog -> SQL compilers I know of:

- Originally from Mozilla, now independent: https://github.com/qpdb/mentat

- From Google: https://logica.dev/





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: