From the course: Software Architecture: Patterns for Developers

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Event sourcing

Event sourcing

- [Instructor] In this video, we'll dive into event sourcing. In event sourcing, instead of storing the current state of our data in the database, we store the events that happened to our data. An event is defined as something that occurred in the past. If you want to know what the current state is of a certain entity, you apply all previous events to a new object. This is called rehydration or event replay. An example can clarify things. Traditionally, we retrieve a record from our database, for example, a customer with the name Amina, then we update the name to Sophia and store that value in the database. There's no trace of the original name. In event sourcing, we could see two events, a first one indicating a customer with the name Amina was created, and the second indicating the name was changed. To get the latest version of our customer, we replay these events and end up with an object representing our customer named Sophia. A great advantage of event sourcing is the trace you…

Contents