Search code examples
datomic

If you discover a fact after the fact, how do you Datomic?


My understanding of EAVT is that T has to be when the fact is inserted into Datomic. Often in my work facts can be inserted into the system months after they occurred. Clearly I can add an "at" attribute to my schema, but this seems to defeat much of the value of Datomic. Are there patterns or techniques for conveniently handling this temporal disconnect?

The main problem I want to avoid is:

t=1: I receive a fact that at t=0 x=5
t=3: I receive a fact that at t=2 x=6
t=5: I receive a fact that at t=4 x=7

What was x @t=2.5?

To answer this question I think I have to query the entire history of x, and traverse a custom at field. Or do some sort of binary asof search. Neither seems very appealing.


Solution

  • In principle, the :db/txInstant is a record of when a fact became known to the system. If the fact that became known was "when some event happened," I see no problem with adding an attribute for that knowledge, e.g. :person/birthday or :historical-event/date-time.

    The only time I avoid adding date attributes is when "when this became known to the system" and "when this occurred" are the same by definition. For example, "when did the user create this todo item" can be defined as the :db/txInstant for when the todo item entered the database.