4 ms·
Can you elaborate on "datalog queries blows SQL out of the water"?
by garysieling 10y ago
Can you elaborate on "datalog queries blows SQL out of the water"?
- hcarvalhoalves 10y agoNot OP, but at my company we're heavy users of Datomic. Some examples: - Declarative and pattern matching make it elegant to read. E.g., find me the ids of all customers invited by a customer named "Joe": {:find [?customer] :where [ [?inviter :customer/name "Joe"] [?customer :customer/invited-by ?inviter]]} - Syntax more appropriate for code generation and introspection (since it's just a bunch of nested lists). A big plus when pairing w/ Clojure. - Allows recursive queries. - You can reference metadata associated to any transaction that ever touched any attribute in your database within the same query constructs. E.g, find me the time customer name was last modified: {:find [?customer ?name ?last-modified] :where [ [?customer :customer/name ?name ?tx] [?tx :db/txInstant ?last-modified]]} - You can easily query the entire history of records. E.g, find me the name every customer ever had, w/ date of modification {:find [?customer ?name ?last-modified] :where [ [?customer :customer/name ?name ?tx true] [?tx :db/txInstant ?last-modified]]} Almost the same as query above, only difference would be executed using a different Datomic API call (http://docs.datomic.com/clojure/#datomic.api/history http://docs.datomic.com/clojure/#datomic.api/history). - You can easily execute a query against how your database looked like months ago. Same thing: would look like the query above, but executed using a different API call (http://docs.datomic.com/clojure/#datomic.api/as-of http://docs.datomic.com/clojure/#datomic.api/as-of) I would say these are the main ones, but there's more.
- garysieling 10y agoAwesome, thanks! The recursion looks compelling. I'd be interested to know if anyone has compared Datalog and Neo4j/Cypher.
- samuell 10y agoCypher doesn't have named queries (and thus not recursive ditto either), AFAIK. I asked some Neo4j guys on a meetup some time ago, and they didn't even seem to really understand the question at first. It's a pity. I'd be very happy to use Neo4J if it had.
- garysieling 10y agoInteresting. It seems like to query a graph is implicitly recursive (especially compared to SQL), although I can see how something like pagerank might need more.
- hcarvalhoalves 10y agoNeo4j focuses on modeling nodes and it's relationships, and allows you to attach metadata to the later, but doesn't really have transactions as first-class objects. Datomic focuses on modeling facts (entity-attribute-value). This is a very stable data representation that allows modelling tables, documents or graphs [1], on top of carrying transaction explicitly on an additional index for the time-travel magic. I guess Neo4j might make a good DB for ETL-ing into and running certain kinds of analysis. [1] https://hashrocket.com/blog/posts/using-datomic-as-a-graph-database https://hashrocket.com/blog/posts/using-datomic-as-a-graph-d...
- garysieling 10y agoAwesome, thanks. I'm building a search engine (https://www.findlectures.com https://www.findlectures.com) and I've been looking at ETL-ing the data into/out of Neo4j to do some data augmentation, but the history feature of Datomic is really compelling if I used it as a primary data store.