Simply put Event Sourcing is:
Storing a series of events and rebuilding a state within the system by replaying that series of events
So, we maintain an event store (either in a relational database or a document store like Mongo or some other NoSQL database) and keep appending the events generated by the system to the same store. Hence to calculate the current state, we play all the events generated.
For example, in the case of an airline ticketing system, that keeps track of the tickets sold and available for an airline, if a user requests to book tickets on a flight, the system would check the current tickets available. And if there are spare seats available, it would book them for the user. The system would also keep track of the cancellations. There can be two ways of designing such a system:
- We maintain the current spare seat count in an integer (or in a row...