# CQRS/ES Scenario

Assuming we were building a dedicated "Comment" service which is structured in topics and comments like so:

Topic #1
  Comment #1
  Comment #2
  Comment #3

Topic #2
  Comment #1
  Comment #2
    Comment #1
    Comment #2
    Comment #3
  Comment #3
1
2
3
4
5
6
7
8
9
10
11
12

So we deal with lists of Topics and Commments (like in traditional CRUD) and want to keep an extra projection Threads which provides a tree-like preview combined of Topics and Comments.

# Write Models (Aggreggates)

All write commands get stored as event within the events collection. Appending any change as event to that collection is optimized for fast writes.

  • Topic: a single topic aggregated from events collection
  • Comment: a single comment aggregated from events collection

# Read Models (Projections)

Read models store their current (projected) state within dedicated collections. Their data models and collections are optimized for fast reads.

  • Topics: a list of topics stored in topics collection
  • Comments: a list of comments stored in comments collection
  • Threads: a list of threads stored in threads collection

As you see: While virtually writing to 2 data models we can now maintain 3 differnet representations of these models on the read side. In addition we might even add another 4th read model by replaying all exitings events throughout it's projection.

Last Updated: 11/27/2019, 3:58:28 PM