After reading dozens of articles and watching hours of videos, I don't seem to get an answer to a simple question:
Should static data be included in the events of the write/read models?
Let's take the oh-so-common "orders" example.
In all examples you'll likely see something like:
class OrderCreated(Event):
....
class LineAdded(Event):
itemID
itemCount
itemPrice
But in practice, you will also have lots of "static" data (products, locations, categories, vendors, etc).
For example, we have a STATIC products
table, with their SKUs, description, etc. But in all examples, the STATIC data is never part of the event.
What I don't understand is this:
- Command side: should the STATIC data be included in the event? If so, which data? Should the entire "product" record be included? But a product also has a category and a vendor. Should their data be in the event as well?
- Query side: should the STATIC data be included in the model/view? Or can/should it be JOINED with the static table when an actual query is executed.
- If static data is NOT part of the event, then the projector cannot add it to the read model, which implies that the query MUST use joins.
- If static data IS part of the event, then let's say we change something in the
products
table (e.g. typo in the item description), this change will not be reflected in the read model.
So, what's the right approach to using static data with ES/CQRS?