Persistence of data using event sourcing

1

I recently heard about Event Soucring in a Greg Young video and found an idea that seems to be very useful on many systems where having a history of data is important.

What I understood is that instead of persisting the state of the entities of the system and updating as the state changes, we persist events, which correspond to the state changes.

From what I understand, we persist the events corresponding to each aggregate present in the domain model, which makes sense, since the aggregates are treated as a whole in the domain.

My only question is: how does one persist in events? Persisting state is no longer trivial in relational databases, but we have been able to deal with this by mapping properties to table columns.

On the other hand, is it not clear to me how to persist events in practice? Do we even use relational banks, or do we have to use a different type of bank specifically for this?

The only thing I thought would be to have a relational database, with a table for each event of each aggregate. So if an aggregate is Pedido representing a request, we would have tables PedidoCriado , PedidoAlterado , PedidoCancelado with data referring to the event.

But that does not seem the right way, because it seems like it can become a mess over time. Also, when you change a request, many properties are the same. If the idea is to save only the deltas, only the event itself, many columns would go blank.

Anyway, if I want to use Event Sourcing and persist the events rather than persist the state, how should I persist these events? What is the correct mechanism for doing this?

    
asked by anonymous 28.07.2016 / 16:56

1 answer

1

The type of database that you use to implement Event Sourcing is indifferent. I believe that therein lies the fact of the doubt on this topic: it is not about applying different tools to solve new problems but rather to see old problems in a different way and to model them differently. This is independent of the tool used.

Despite the recent hype, the idea of Event Sourcing is not new. It already existed in 2000 and was published in 2005 by Martin Fowler: link

His site explains the idea very well:

LookingattheinternetIalsosawthispresentationwhere,inpractice,itexplainswelltheproblemsandadvantagesofEventSourcinganddoesthisparallelbetweeneventsandmappingofrelationalobjects.

link

I hope it helps!

    
01.08.2016 / 16:27