Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Datomic JFall 2012

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Datomic JFall 2012

Introduction to Datomic for JFall 2012

Avatar for Daan van Berkel

Daan van Berkel

November 07, 2012

More Decks by Daan van Berkel

Other Decks in Technology

Transcript

  1. Background A people without the knowledge of their past history,

    origin and culture is like a tree without roots. - Marcus Garvey
  2. Background Cost drives design if memory is expensive update in

    place this loses information http://en.wikipedia.org/wiki/Relational_database
  3. Background Properties of RDBS ACID •Atomic •Consistent •Isolated •Durable "All

    or nothing" if one part fails, it should fails entirely
  4. Background Properties of RDBS ACID •Atomic •Consistent •Isolated •Durable "I

    am the law" data should always meet the constraints set out by the design
  5. Background Properties of RDBS ACID •Atomic •Consistent •Isolated •Durable "Play

    nice" concurrent executions should not be aware of each other presence
  6. Introduction Datomic stores Datoms Representation of a fact •entity •attribute

    •value •transaction Examples [Daan ate pancakes T37] [Daan drank milk T37] [Daan ate pizza T51] [Daan wentTo gym T79] [Mink wentTo gym T79]
  7. Introduction Change database by •Adding •Retracting in a transaction Preserve

    history [:db/id 37 :likes "fish"] [:db/retract 37 :likes "fish"]
  8. Introduction Query by [:find ... in ... where ...] •Variables

    •Inputs •Clauses [:find ?e :in $ :where [?e :likes "fish"]]
  9. Demonstration •BeanShell •Seattle Communities Community - name - url -

    neighbourhood - category - org type - com type Org Type - community - commercial - nonprofit - personal Com Type - email-list - twitter - facebook-page - blog - website - wiki Neighbourhood - name - district District - name - region
  10. Exploration Transaction •Query over time [ :find ?v ?t :in

    $, ?a :where [?a :account/balance ?v ?t] ]
  11. Exploration Invoking functions all community names with a name less

    than "C" [ :find ?n :where [?e :community/name ?n] [(.compareTo ?n "C") ?res] [(< ?res 0)] ]
  12. Exploration Full Text Search [ :find ?e ?n :in $,

    ?k :where [(fulltext $ :community/name ?k) [[ ?e ?n ]]] ]