In monolithic systems, everything seems to be fully consistent. To achieve consistency, a lot of logic is outsourced to the database engine and becomes implicit, hard to figure out at a glance, and hard to test. Database transactions are frequently used to ensure that multiple-state mutations are executed at once. If the data becomes inconsistent, that usually means failure, and that requires an extensive investigation to fix the issue.
Domain-Driven Design (DDD) means avoiding complex graphs of entities. Instead, developers need to find a minimal logical set of entities that belong together and therefore need to be updated together to ensure consistency. Such a group of entities is called an aggregate.
The following topics will be covered in this chapter:
- Command handling as a unit of work
- Consistency and transactions
- Aggregates and aggregate root patterns...