Datalog is a truly declarative logic programming language that syntactically is a subset of Prolog. It is often used as a query language for deductive databases. In recent years, Datalog has found new application in data integration, information extraction, networking, program analysis, security, andcloud computing.[1]
parent(bill,mary). parent(mary,john).
ancestor(X,Y) :- parent(X,Y). ancestor(X,Y) :- parent(X,Z),ancestor(Z,Y).
It is used by Datomic (that is based on Clojure)
The Datomic Information Model @ InfoQ
by Rich Hickey (creator of Datomic & Clojure)
If you had a database containing these datoms (where sally, fred and ethel are stand-ins for their entity ids):
[[sally :age 21] [fred :age 42] [ethel :age 42] [fred :likes pizza] [sally :likes opera] [ethel :likes sushi]]
We could ask a query like this:
;;who is 42? [:find ?e :where [?e :age 42]]
And get this result:
[[fred], [ethel]]
.
No comments:
Post a Comment