Dive into CQRS

This article is a synopsis of the Clarified CQRS material .





Before you start understanding CQRS, you need to understand the two main driving forces behind it: collaboration and obsolescence.





Collaboration refers to situations where multiple participants use or modify the same dataset, regardless of whether they actually intend to collaborate. There are often rules that specify which users can make modifications. And these modifications may be acceptable in one case and unacceptable in another. The user can be a real person or software.





Obsolescence refers to the fact that, in multi-user systems, once data has been shown to a user, the same data may subsequently change and become obsolete. Almost any system that uses caching, for example to improve performance, operates with outdated data. This means that you cannot completely trust the decisions made by our users, since they could be made based on outdated data.





Standard layered architecture does not address any of these problems. While putting all the data in a single database can help improve collaboration, obsolescence tends to be exacerbated in such an architecture by the use of caching as a performance tool.





Fig. 1.  - Model CQRS
Fig. 1. - Model CQRS

AC . , (Commands โ€“ CQRS). (Queries โ€“ CQRS)





(Queries)

, , , ? , , ?





, , , , , . .





, , โ€“ , , , , ?





? ? SELECT * FROM MyViewTable . . . - (, ).





, . , . , . , .





, , . , , .





. , , . โ€“ .





, , .





, , . (, .). , . , โ€“ . . ?





, , . , , , , .





, , , . .





(CQRS).





(Commands)

CQRS , . , Excel ( , โ€“ ), .





, , . , , . , ( ). , .





, , . - , , - , , .





, , , - . - , - . , . , - .





, , . - , , . , . , , , .





, , , .





UIs

(Queries) . , , , .





UI , , , , , . , , ID . , ID (int, guid .).





, , โ€“ . - .





, , . , , .





, . ยซยป . , ? -?





, , , , . . , ? , ?





( ), , , , : ยซ, ยป. , .





, , โ€“ . , โ€“ .





, . , , โ€“ .





- , , , . . , , , , .





, , , .





1 , AC, AC, . , , , . , , .





(service layer)

. , CQRS, , , , . .





, . , , , ? โ€“ , , .





, , , , .





?

1 , , . , , .





, โ€“ , (CQRS). , , ?





ยซยป? ? ยซ ยป?





, , . , , .





, โ€“ , .





, , , , , ? , , ? key-value. - ? , .





, . , , CQRS.





, , , , . :





MakeCustomerPerferredCommand โ†’ CustomerHasBeenMadePerferredEvent





. , , .





, , . .





CQRS , . CQRS, - (SOA), . , -, -, .





, -, , .





CQRS . , , .





- CQRS, . , . , , , .





CQRS , -.








All Articles