The relation of Event Sourcing with CQRS
We mentioned, at the beginning of Event Sourcing section, that we will discover how CQRS fits into the larger picture, so let’s now combine all of the concepts we learned in the previous sections. Alright! Basically, with CQRS, the way you write data is different from how you read it. In the past, you might have just used one database for everything. You could do operations such as inserting data and then get it right back out of the same place, and that works fine if you’re just doing basic create, read, update, and delete operations. But sometimes you might want to scale how much you can write versus read separately. Or maybe you need different views of the data for reading versus writing. That’s where CQRS comes in.
Figure 2.8 shows how commands and queries interact with the database:
Figure 2.8: Representation of CQRS pattern
The basic idea is that you split up how you write data from...