Learn Datomic Datalog
This interactive website will help you learn how to query a Datomic database using Datalog.
Datalog is a declarative, logic-based query language. Like SQL, you describe what you want rather than how to find it. Unlike SQL, Datalog works by matching patterns against facts, making it a natural fit for Datomic's data model.
By the end of this guide you will be able to model your own data, filter and aggregate query results, and traverse relationships between entities. You will also parameterize queries, pull whole entities back as data, write reusable rules, and query the database as it looked at any point in its history. Every example runs against a real database of all 151 original Pokemon.
Who this is for
This guide is for anyone curious about querying with Datomic, whether or not you've used it before. No SQL experience is required, though the comparisons above will click faster if you have some. What matters more is being able to read a little Clojure, since every query on this site is Clojure data:
[...]is a vector, an ordered list.:like-thisis a keyword, Clojure's version of a name or a column label.- A symbol starting with
?, like?name, is a logic variable: a placeholder the query fills in. - Text in
"quotes"is a string. ,is whitespace to Clojure. Some examples use,,,to visually separate parts of a query.
For a deeper look at Clojure's data syntax, see the official reader reference.
No Pokemon expertise is required either. Stats, types, generations, and terms like "super-effective" or "legendary" are explained as they come up, using the data itself.
Click the "Run" button below to run your first Datomic Datalog query.
That was a query. We will look at the facts it matched first, then at how a query is put together, and last at how the data got into the database.
Edit the query above to return Pokemon of other types like Fire or Electric.