I've been wondering about what is a perfect use case for CQRS where the benefits overcome the complexity and the cost with come with the package. So for me to better understand it, I want to share with you a theoretical use case and we can see together whether it's a good CQRS fit or not, and if not what alternatives would be good in this case.
Let's say we have the following very simple model: As we can see, we have departments which have multiple students where they can pass exams on subjects which are classified into categories. Very simple.
Let's also say our solution have a screen where we want to display all these information. Here's our ugly UI for this page:
As you can see the information shown in the table must be extracted from all the entities shown above. So we have a lot of joins.
Supposing that our client have w very successful online school with millions students. And they do not tolerate performance issues, so the solution must be as fast as possible.
It's clear that there are multiple joins when displaying this page, so to improve the overall readability we went ahead and started experimenting on CQRS. We need to add a new database for read operations which stores all the above information in a single row, so the read model for our view is as follows:
This will definitively make reading faster but it will also make thing more complicated. For example, we need an event source to publish event that sync the read database with the write database, etc...
So my question is, in this particular use case, is CQRS beneficial ?