Skip to content

Basics

  • Stores historical events
  • Datalog is the query language
  • Append-only (impossible to edit/remove events)

Entity

  • Entity is every symbol created by a datom
  • Each entity is referenced with a unique id (:db/id). This id is automatically created

Schema

  • Schema is the set of attributes that can be associated with the entities of a database
  • An attribute is defined by:
  • :db/ident: unique name for the attribute
  • :db/valueType: type of data to be stored in the attribute
  • :db/cardinality: whether to store a single value or a collection of values
  • :db/doc (optional but recommended): docstring of the attribute
;; attribute 1
{:db/ident :movie/title
 :db/valueType :db.type/string
 :db/cardinality :db.cardinality/one
 :db/doc "The title of the movie"}

;; attribute 2
{:db/ident :movie/genre
 :db/valueType :db.type/string
 :db/cardinality :db.cardinality/one
 :db/doc "The genre of the movie"}

;; attribute 3
{:db/ident :movie/release-year
 :db/valueType :db.type/long
 :db/cardinality :db.cardinality/one
 :db/doc "The year the movie was released in theaters"}