Our first client in Saudi Arabia
April 11, 2022
October 5, 2021 • Development
CQRS is deciphered as Command and Query Responsibility Segregation. It is an architectural design pattern which states that we must separate the operations for reading the data from the operations for writing or updating the data.
CQRS is not a pattern that encompasses the whole application. It is a concept that builds on Domain-Driven Design (DDD).
An important strategic concept of DDD is the so-called Bounded Context. In a typical application, there are multiple bounded contexts, any of which can be implemented the way it makes sense.
One can split development tasks between people easily. The top people can work on domain logic leaving the usual stuff to less skilled developers.
Difficult business logic
CQRS helps avoid mixing domain logic and infrastructural operations.
Helps achieve great read and write performance (because queries can be optimized to do fast read operations).
Queries are a key element used for reading data. How are they helpful in the implementation process of CQRS?
1. They offer the possibility of having one table for each view. Thus, the client can simply SELECT * FROM MyViewTable.
2. There is no need for a relational database.
3. They can be scaled horizontally.
Here are some tips:
1. Use the main data store for commands.
2. Queue commands and have notifications about their execution statuses.
3. Remember there’s no need to keep the server always on since queues can hold requests.
4. After the command was executed, update the main database and query the data store concurrently.
April 11, 2022