datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
alidlorenzo 2020-08-01T14:50:11.067200Z

What exactly counts as an entity in Datomic? Is it whatever datoms are transacted together as part of a single transaction form? I’m asking bc I’m pondering what would be the best way to model a belongs-to relationships of different namespaced datoms that are always created together? e.g. an account and a user should they be transacted* together as a single db entity?

{:tx-data [{:account/username "admin"
            :user/email "<mailto:admin@domain.com|admin@domain.com>"}]}
or would it be better to make them separate db entities and give one a db ref to the other? 
{:tx-data [{:account/username "admin"}
           {:user/email  "<mailto:admin@domain.com|admin@domain.com>"
            :user/account [:account/username "admin"]}
i imagine making them a single db entity and adding a db ref would redundant since the datom would be referencing its own db id
{:tx-data [{:account/username "admin"
            :user/email  "<mailto:admin@domain.com|admin@domain.com>"
            :user/account [:account/username "admin"]}