January 3, 2020

Where's my data?

Speaker

David Chelimsky, Consultant at Cognitect

Thoughts

I like the idea expressed in Datomic because of the simplicity of the model. I confess that I haven’t studied as much as I did with Datomic to other databases such as PostgreSQL, but the idea of distributed database and immutability has very nice properties.

I am currently working in a project using Datomic as my core database. Let’s see how this experience is going to turn out.

Quotes

Entity: a collection of facts with the same entity id

The attributes themselves are entities.

Datomic maintains a small segment of your database at the client level

Code snippets

Returns a collection

[:find [?e ...]
 :where
  [?e :artist/country :contry/ES]]

How to express a join, also called conjunction:

[:find [?e ...]
 :where
  [?e :artist/country :contry/ES]
  [?e :artist/type    :artist.type/group]
  [?r :release/artists ?e]
  [?r :release/year 1970]]

How to express an explicit or, also called disjunction:

[:find [?e ...]
 :where
  [?e :artist/country :contry/ES]
  [?e :artist/type    :artist.type/group]
  [?r :release/artists ?e]
  (or [?r :release/year 1970]
      [?r :release/year 1980])]

Recomendations

  1. put more restrictive patterns first

Tags: nice-code-snippets clojure datomic