we took a look at the Axon framework and find it really impressing.
Then we looked at it’s SQL schema and it does conflict with our conceptual model of aggregates and aggregate roots.
Please correct me where I am wrong with the following
- A single event store (event store table) can store aggregates from different aggregate roots.
- Each aggregate root gets it’s own sequence number which is incremented on each aggregate/aggregate root event.
- The aggregate identifier identifies an aggregate inside a single aggregate root.
- The aggregate identifies is unique inside a single aggregate root.
- The application code is responsible for generating the aggregate identifier.
It is our understanding that aggregate identifiers of different aggregate roots are independent from each other and that
each aggregate root opens a new “namespace” for identifiers.
That means in our opinion that for each event the tuple (aggregate root identifier (type), aggregate identifier, sequence number)
is unique but the tuple (aggregate identifier, sequence number) is not because different aggregate roots may use identical ids and use identical sequence numbers.
But the domain event table (public.domainevententry) has the following unique constraint:
“domainevententry_aggregateidentifier_sequencenumber_key” UNIQUE CONSTRAINT, btree (aggregateidentifier, sequencenumber)
And the table public.snapshotevententry has the primary key:
“snapshotevententry_pkey” PRIMARY KEY, btree (aggregateidentifier, sequencenumber)
We expect that this leads to constraint violation because the aggregate identifiers are not independent between aggregate roots
because the type is missing. And the type seems also not to be used as a selector when querying the database.
What do we miss?