What is event sourcing in databases?
Short answer: Event sourcing is a pattern where the state of an application is determined by a sequence of events, rather than storing the current state directly in the database.
Explain a bit more
How it works: Instead of storing the current state of an entity, each change to that entity (event) is stored as an immutable event in an event store. The state can be reconstructed by replaying the events. Advantages: You have a complete audit trail of changes. Enables eventual consistency and can scale well in distributed systems. Use cases: CQRS (Command Query Responsibility Segregation), systems requiring full audit logs, and systems that need to capture historical data changes.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png