Command and Query Responsibility Segregation (CQRS)
Traditionally, people interact with Information Systems through a CRUD data store. Read and Write Data models are often the same. As the complexity of the application increases, multiple representations of the information are created, all referring to one common data (conceptual) model. This can lead to data/resource contentions, performance slowdown and in some cases, security issues.
Solution: Separate the Read and Write models
- This can be done by creating separate schemas or different databases for the Read and Write operations. All reads from a single data store and all Writes/Updates to a separate data store
- Creating separate databases provides additional isolation that helps with scalability and performance
- The Write databases can be relational while Read databases can be No SQL document-based
- This approach not only provides separation of concerns but also allows each data store to independently scale based on its workload
- The important consideration in this model is to maintain sync between the Read and Write stores. This is typically achieved through publishing events from the Write store and consumed by the Read store