Event Sourcing and SQL Server Multiple Relational Tables

We use event sources with SQL Server 2016. We have a common client application, each of which is marked with CustomerId and receives a separate position in the event store. This is the primary identifier for writing event store entries. Product applications have many different relational things (which have no instructions other than natural keys), each client has several addresses, accounts, several purchase orders. The event log of the record will be displayed in the tables of the relational database in any way that we choose. In databases, we try to bind a connection using surrogate keys instead of natural keys.

Can surrogate keys be guides, or can we use integers (possibly Identity) for faster combining?

Remember that the only main identifier in the event recording repository is the Guid application from the client ID application (large json blob with the attributes of the table columns that we want to model), but the tables of child relations that can change at any time in the reading model do not have a child pointer to the record event store.

+5
source share
1 answer

Yes, you can use everything you need in a specific read model implementation, but you need to consider that the read model should be rebuilt at any time . Thus, when restoring the read model it can use other surrogate identifiers or simply implement it in such a way that every time it gets the same identifiers (I mean the Autoincrement function).

PS why aren't you trying to denormalize your data? The event sourcing is common to avoid using connections instead of making them faster in the read model .

+3
source

Source: https://habr.com/ru/post/1271915/


All Articles