51. Datalog is...
• A query language
• Not Turing complete
• Explicit
• Simple
• to use
• ... and implement
• ... kinda
52. History
• 1977: Gallaire and Minker's Symposium on
Logic Data Bases
• 1980s: Nail, LDL, Coral
• 1995: Stonebraker and Hellerstein declare
"no practical applications …"
• The dark years...
53. History
• 2002: Binder, a logic-based security language
by DeTreville
• 2000s: Declarative networking, bddbddb,
Orchestra CDSS, Doop, SecureBlox,
Dedalus, more
• 2010: The Declarative Imperative by
Hellerstein!
• Today: Bloom, Cascalog, Datomic,
LogicBlox, more
54. Datalog is also
• Declarative logic programming with
termination
• Recursive queries
• Implicit joins
73. Time
• Total ordering of transactions
• Every datom retains a reference to its
enclosing transaction
• Transactions are first-class entities, can have
their own attributes
74. Time
• You can obtain the value of the db as-of, or
since, a point in time, or both
• without parameterizing your logic with a
time argument
• You can also get the entire history of an
entity!
75. Datomic is also
• Fully navigable lazy entity maps
• Query across databases
• Optimistic and pessimistic concurrency
• “Upsertting”
• http://datomic.com
95. Aggregation
• Partition result tuples along logic variables
• Execute aggregators for each logic var
Pre- Post-
Aggregation
aggregation aggregation
96. Post-aggregation
• Execute the the remaining filters and
functions on dependent aggregator output
Pre- Post-
Aggregation
aggregation aggregation
97. Example
Pre- Post-
Aggregation
aggregation aggregation
117. Pluggable Optimizers
• Order agnostic is a win
• Some orders are better than others
• Plug in your own optimizer
• That knows your data
• Will not affect other Datalog engine
optimization techniques
118. • Rich Hickey, Stu THX!
Halloway, Clojure/core
• Clojure/dev
• Manning Publications
• The fam
• You
137. Function call
semantics: fn call arg
(println "Hello World")
structure: symbol string
list
126
138. Function definition
define a fn fn name
docstring
(defn greet
"Returns a friendly greeting"
[your-name]
(str "Hello, " your-name))
arguments
fn body
127
139. It's all data
symbol symbol
string
(defn greet
"Returns a friendly greeting"
[your-name]
(str "Hello, " your-name))
vector
list
128
Editor's Notes
\n
\n
\n
\n
\n
\n
Cancer of the rectangle\n
\n
\n
\n
\n
\n
Mistaking the menu for the meal.\n
\n
* One Size Fits All: An Idea Whose Time has Come and Gone\n\n
* With a severe line between\n
\n
* We’re surrounded by data\n
* We need better ways to leverage our data, in all of its facets\n* Unify the two?\n
\n
\n
\n
\n
* Ground terms surrounding variables\n
\n
\n
\n
\n
* The resulting substitution between two forms that provides a symmetry between the two forms\n* Amalgamation of the bindings of either gives the MGU on subst\n
\n
\n
* unromantic view of childbirth\n* genealogy is the killer app\n
\n
\n
* backtracking\n* depth-first tree traversals\n
\n
* Bill’s descendents?\n
* Flip order fixes!\n
\n
\n
* This is not completely bad, but writing Prolog is often many balancing acts.\n* Like this\n
*generically cut is a way to prune branches from the search tree, but...\n
* This kills the idea of data as code\n
* Performing IO\n* This kills the idea of data as code\n
* Make some compromises?\n
\n
\n
\n
\n
\n
\n
\n
* Relation patterns unify across the existing data\n
\n
\n
\n
\n
* \n
\n
* the gist of datalog\n* datalog is a family of languages\n