I think I understand the idea of the read model in the context of ES + CQRS (please correct me if not). However, I still have a few doubts about using it in the context of ‘serious’ reporting. Let us say I use a relational db plus some ORM to crud my read models. One basic ‘summary stats read model’ could look like this:
class SummaryStats1
{
public Guid TypeId { get; set; }
public string TypeName { get; set; }
public Guid SubTypeId { get; set; }
public string SubTypeName { get; set; }
public int Count { get; set; }
}
Given an event:
TypeId = 3acf7d6f-4565-4672-985d-a748b7706a3e
TypeName = Bla1
SubTypeId = 41532aa1-f5d1-4ec4-896b-807ad66f75fc
SubTypeName = Bla2
The normaliser would:
(1) Check whether there is an instance of the above combination (defined by TypeId, TypeName, SubTypeId, SubTypeName) (2) If there no instance it would create an instance and set Count to one. If there is it would increase the Count by one.
Is this the acceptable reporting approach? I guess one can run very efficient selects against this de-normalised data structure (for filtering and other sql ‘projections’):
SELECT TypeName, Sum(Count) FROM SummaryStats1 GROUP BY TypeName
Would CQRS/ES experts agree with this? Is this 'the way' of doing things (i.e. create these dedicated report read models)? Any references to source code/real examples would be very much appreciated.