datomic

Ramin Soltanzadeh 2025-10-19T15:22:23.902329Z

Hi, Do the fact-based semantics of Datomic—as opposed to rigid-object-structure-based semantics of mainstream DBs—help solve the problem of correctly discriminating between when changes should and shouldn't propagate to related entities? Here's an example to illustrate what I mean: • Alice has been friends with Bob for 5 years. Bob changes his name to Charlie. In 2 years, Alice will have been friends with Charlie for 7 years. • Alice visited Bob's house 3 years ago. Bob has since moved to a new house. Alice has never visited Bob's house.

helios 2025-10-20T14:42:21.607479Z

To rephrase a bit what @me1740 said, what helps in both cases (at least to me) is to reason based on entities. You 'traverse' the relationship to arrive at the proper entity and you establish a new fact directly with the entity regardless on how you got there. • Alice is friend with the person, regardless of their name. You figure out the first time who is this person by finding the person whose name is bob. Its identity is still the same. • Alice visited the house, regardless of who it was at the time. Alice has not visited the new house.

Ramin Soltanzadeh 2025-10-20T16:58:57.950149Z

Thanks for the answers. My examples were probably a bit poor, and I agree it's a data modeling question. I thought perhaps Datomic (or its idioms, if that is even a thing) had some "best practices" to help with this problem. I think I'm mostly after finding out if this is an established problem (perhaps with a name) that I can learn more about. Imagine for example that Bob didn't actually move to a new house; the government had just entered the wrong address in their system. Bob's address has changed since Alice visited the house, but she has in fact visited the current house with the "new" address! How is this information modeled differently than the one where Bob moved to a new home? Spontaneously it feels rather "imperative" and error-prone to handle these things on a case by case basis and improvizing a solution each time. I feel like there probably is a smart way to design relations to account for this that I'm simply unfamiliar with.

cjohansen 2025-10-20T17:07:29.098549Z

You don't really solve these on a case by case basis. You model relationships (which house someone is in, the house address etc) as entities. This way you have all the relationships you need, and each entity has their own life cycle. You can ask any matter of questions on the time line. "What house did Bob live in when Alice met him?" "What's the current address of Bob's house?" "Which houses did Bob live in before meeting Alice?" "Has Alice ever been to a house that Bob used to live in, to visit one of the house's previous owners?" All of this is straight forward to answer with proper entity relationships in Datomic.

Ramin Soltanzadeh 2025-10-20T17:45:15.824679Z

Thanks, makes sense. I suppose I've been overthinking it.

benoit 2025-10-19T18:57:24.280309Z

If the friendship relationship is between entities A and B. A has the name "Alice", B has the name "Bob". If later the B entity changes its name to "Charlie", it does not change the friendship relationship. Similarly Bob inhabited two different houses which have two distinct identities. Alice visited the first one but not the second. It depends on how your model your data and the questions. We could also have asked whether Alice has ever visited Bob's house, whatever house it is. It is a data modeling question more than a question about the capabilities of a particular information model.

cjohansen 2025-10-19T19:46:02.192399Z

I second @me1740's points, but let me say that I would be surprised if you managed to model your data in a way that didn't trivially give the correct answer for the two concrete examples.