State data in traditional applications is represented through a set of entities. The entities are stored in a single data repository against which two types of operations can take place.
- Commands: Operations that modify state
- Queries: Operations that read state
An operation cannot both update state and return data. This distinction of operations helps simplify understanding the system. The segregation of operations into commands and queries is called the Command Query Separation (CQS) pattern. The CQS pattern requires the commands to have void return type and the queries to be idempotent.
If a relational database such as SQL Server is used for storing state, the entities may represent a subset of rows in one or more tables in the database.
A common problem that arises in these systems is that both the commands and queries are applied to the same set of entities. For example, to update the contact details of a customer in a traditional e-commerce...