Fork me on GitHub
Tobias Sjögren04:10:03

“In order for a keyword to appear in the A position in a datom, it must have previously appeared in the V position.” Correct? (trying to understand what a keyword really is…)

Jakub Holý (HolyJak)08:10:06

Keyword is just a data type intended to be used as an identifier, typically for properties inside maps. Attributes - your A - in datomic are identified by keywords and before you can use an attribute, you must define in, so yes, the keyword will first appear in the V position of [<attribute entity id> :db/ident <the keyword>] .

👍 1
Tobias Sjögren08:10:53

OK. Although you probably don’t want to do it - it would be possible to use the <attribute entity id> instead of the keyword in the A position, right?

Jakub Holý (HolyJak)08:10:16

I think so. If you look at the raw datoms, the E and A positions are just numbers.

Tobias Sjögren08:10:59

Do you happen to know the entity ids for the built-in attributes?

Jakub Holý (HolyJak)08:10:02

They are not fixed between DB instances. Look at their corresponding datoms (I do not remember the correct function for that)

Tobias Sjögren08:10:00

From what I’ve heard it is this:

(d/create-database "datomic:")
 (-> (d/connect "datomic:")
     (d/seek-datoms :eavt 0)
     (->> (group-by :tx)


On my current version of Datomic Free it is the below list. But it's an implementation detail, at least it is not documented anywhere, and you shouldn't rely on it.

{:db.type/instant 25,
    :db/excise 15,
    :db.type/boolean 24,
    :db.unique/identity 38,
    :db/fn 52,
    :db.type/bytes 27,
    :db/index 44,
    :db/unique 42,
    :db.part/user 4,
    :db.lang/clojure 48,
    :db.excise/beforeT 17,
    :db.part/db 0,
    :db.bootstrap/part 53,
    :db.sys/reId 9,
    :db/valueType 40,
    :db.type/string 23,
    :db.type/keyword 21,
    :db/txInstant 50,
    :db.type/ref 20,
    :db/noHistory 45,
    :db/isComponent 43,
    :db/lang 46,
    :db/fulltext 51,
    :db.unique/value 37,
    :db/retract 2,
    :db.lang/java 49,
    :db.part/tx 3,
    :db/cardinality 41,
    :db.excise/before 18,
    :db/ident 10,
    :db/code 47,
    :db/add 1,
    :db.type/long 22,
    :db.cardinality/many 36,
    :db.install/valueType 12,
    :db.alter/attribute 19,
    :db.install/function 14,
    :db.install/partition 11,
    :db.install/attribute 13,
    :db.type/fn 26,
    :db.cardinality/one 35,
    :db.excise/attrs 16,
    :fressian/tag 39,
    :db.sys/partiallyIndexed 8}

👍 1
Tobias Sjögren12:10:40

@U024X3V2YN4 Would you happen to have the raw datoms where these built-in attributes are defined, as plain text?


The datoms are not stored individually, but in segments consisting of thousands of datoms. You can get a high-level picture of the internals here:


Maybe worth pointing out that a single datom can be stored multiple times, once for each index containing it. Every datom is stored separately in the EAVT index and the AEVT index, for instance.


To answer your original question, when a keyword K appears in the A position, Datomic will try to resolve that to an entity E with an attribute :db/ident whose value is K. If it cannot do that, for instance if you never installed such an entity, you'll get an error like "Unable to resolve entity: K".


Such keywords K are called idents, and you can read about it here Probably that whole page is worth a look.


At least I found that page very helpful myself when trying to understand how Datomic named entities and how it looked things up, precisely a point I was quite confused about myself

Tobias Sjögren15:10:20

Concerning keywords: That’s how I understood it - I was a bit unsure after reading that “Keywords resolve to themselves” in the “Programming Clojure” book…

Tobias Sjögren15:10:21

I read a lot from the documentation but still have questions..


Keywords do evaluate to themselves.


If you give Clojure a keyword in, say, the REPL, it will return to you that same keyword

Tobias Sjögren15:10:41

You said a keyword used as an attribute will resolve to an entity id..


I was talking specifically in the context of Datomic transactions. Datomic will take that keyword and try to find a matching entity

👍 1

But that has all to do with how Datomic works, not how keywords are evaluated


It might help to break it down into two steps. First you write some transaction data. And this really is simply data:

[{:db/id "sensor 1" :sensor/humidity 124.0}
 {:db/id "sensor 1" :sensor/humidity 125.0}
 {:db/id "sensor 2" :sensor/humidity 124.0}
 {:db/id "sensor 2" :sensor/humidity 100.0}
 {:db/id "sensor 3" :sensor/humidity 125.0}] 
Then you transact this to Datomic using d/transact. Second, when Datomic receives this, it will notice there are attributes referrred to by keywords, and then try to find matching entities.


I was going through and

(require '[datomic.client.api :as d])
(def client (d/client {:server-type :dev-local
                       :system "datomic-samples"}))
(d/list-databases client {})
=> ["mbrainz-subset" "solar-system" "social-news" "movies" ...]


i thnk we need to add statement , before we printing list of databases

(d/create-database client {:db-name "friends"})


because without that it gave me empty vector

Tobias Sjögren08:10:14

Does anyone know if there are examples of raw datoms data somewhere online?

Tobias Sjögren09:10:09

Do you know what format “db.log” files are in? I can’t read them..

Linus Ericsson07:10:35

The data is stored in either fressian or transit The explicit storage of the various nodes is an implementation detail. the best way to get som example data is to follow the instructions and restore for instance the mbrainz-sampledata.

Tobias Sjögren15:10:37

another area I’d like to know about…

Tobias Sjögren15:10:08

Is someone here using Datomic without using Clojure (if it is even possible) ?

Tobias Sjögren15:10:13

Either Clojure or Java and nothing else?


There are third-party libraries for some other languages

Ben Sless08:10:59

Only JVM langs from what I've seen

Linus Ericsson07:10:53

You can use any JVM-language with the Java wrapper. The datomic implementation in the peer is dependent on clojure since it is implemented in (JVM-)clojure.


Ivar, are you accessing this site from a mobile device?


Trying to determine what the outage is.


@UGJE0MM0W I am seeing everything working from my end can you share specifically what you are seeing?

Robert A. Randolph18:10:41

It appears that there is or was an issue on Zendesk's end with authentication. We were able to log in after clearing all zendesk cookies.

👍 1
Ivar Refsdal07:10:59

Here is what I'm seeing


Hi @UGJE0MM0W I believe we have resolved that just now. I would appreciate independent confirmation so if you have a moment, please let me know.

Ivar Refsdal13:10:24

Yes, I'm logged in now when I refreshed :thumbsup:


Oh great! Thanks Ivar!

Ivar Refsdal13:10:29

No problem 🙂