4. Main features
● No update-in place
● Only assertions and retractions
● Retraction != removal
● Immutable data
● Database as a value
● Flexible schema
● ACID transactions
● Declarative and logic data programming
9. Time
● By-product of ordering states within an entity
● Linear progression
● Morning => ElfenLied
● Afternoon => John
● Evening => ElfenLied
10. Datom
● Basic unit of operation in Datomic
● Also called a fact
● Made up of five parts
11. Datom example
Entity attribute value Tx operation
2439 name John at work add
2439 name John playing retract
2439 name ElfenLied playing add
12. Not only “now”
● Easy access to past and future states
● What was the value of x one week ago?
● What was the state of DB before app crashed?
● Not so easy in RDBMS
13. Everything is data
● Datomic operates on data
● Lists, maps, vectors, keywords, strings
● Even functions, schema is data
● Possible to run queries on all data
14. Transactor
● Single instance
● Handles all writes
● Second instance on stand-by
● Ensures ACID properties
● Notifies transaction submitter and all peers
(other applications) when transaction is
persisted
15. Storage
● Not directly in Datomic
● Leverages storage services:
– DynamoDB
– Riak
– Infinispan
– SQL storages
● Storing segments of datoms not individual ones
● Log storage – chronological
● Indices storage – various orders of datoms
16. Indices
● Entity / Attribute / Value / Transaction
● Sorted order
● EAVT – all datoms (SQL “row-like” view)
● AEVT – all datoms (SQL “column-like” view)
● AVET – unique datoms
● VAET – reference attributes
17. EAVT
● EAVT – all datoms (SQL “row-like” view)
134 name Tim 4592 add
586 city 32 1975 add
586 gender male 4592 add
586 name John 4592 add
976 name Rob 4938 add
18. AEVT
● AEVT – all datoms (SQL “column-like” view)
city 986 32 1975 add
name 134 Tim 4592 add
name 576 Rob 4938 add
name 986 John 4592 add
title 367 Lord Jim 4592 add
19. AVET
● AVET – unique datoms
city 32 986 1975 add
name John 986 4592 add
name Rob 576 4938 add
name Tim 134 4592 add
title Lord Jim 367 4592 add
20. VAET
● VAET – reference attributes
15 author 841 1975 add
32 city 134 4592 add
269 city 576 4938 add
517 city 986 4592 add
male gender 986 4592 add
21. Value of DB
● View of db is a value
● Immutable
● Graph of entities and their attributes
● Direct iterable access to indices
● DB value is a param to queries and functions
22. Datalog
● Default query language
● Declarative – WHAT not HOW
● Logic – patterns matching
● Logical variables
23. Query structure
● :find – projection clause, similar to SELECT
● :in – binding arguments
– Implicit for some queries
● :where – restriction clause
● Most of the logic would be in :where clause
43. DB function components
● Function is a data structure
● Declared with :db/fn
● Optional docs
● Clojure or java
● Parameters
● Require (Clojure) or import (Java) block
● Your code
49. Database filters
● Filter DB value based on some predicate
● Keep only relevant datoms
● Built-in filters and custom filters
● Filters allow for one set of queries operating on
different db values
50. As-of
● Returns DB value “as of” particular point in time
● Ignores any transactions after that point
● Point-in-time could be:
– Transaction id
– java.util.Date instance
– Time-basis (t) of database
● What was the DB last week, month etc?
52. Since
● Opposite of as-of
● Returns value of database that includes only
datoms added after certain point in time
● What were the transactions after X point in
time?
62. ● Still more from Datomic:
– Negation in query
– Retraction
– Excision – true removal
– Partitioning
– Transactions
– with – state with proposed additions
● What would happen if we did x?
– More in depth on covered topics