Reputation: 1974
I have a need to incorporate retroactive events in my event stream and I'm not sure of the best way to implement it.
We need to keep the original event stream unchanged for audit and all of the other standard benefits. The event stream is also temporal in nature, giving us the ability to see the values for any point in history. i.e. The value of x was 10.00 at 5 pm June 1st. Occasionally we find out on June 5 the value of x as was actually 12.00 at 5pm June 1st. In this scenario we refer to 10.00 as the 'as-at' value and '12.00' as the as-of value and we track both of these in the event stream.
Rebuilding the state for the as-at value is a straight forward query from the most recent snap before 5 pm June 1st and all of the events though June 1st.
Where I am hesitant is in rebuilding the as-of state. If there is an as-of correction to the model then then it should be used by default rather than the as-at, but I can't see any way to determine if there is an as-of correction without reading the entire event stream from the point in time until the present (this can be large) and most of the changes will not matter as they will be related to future changes and not the point in time in question.
Is there a different approach I should be looking at here?
Thanks, Chris
Upvotes: 3
Views: 2248
Reputation: 6360
I think what you're referring to is a bitemporal data model. That is, you can answer not only "who won the US Presidential election in 2000", but "who did we think won the US Presidential election in the evening of election day in 2000".
In general, your event stream is not necessarily built to answer all your queries and bitemporal queries efficiently. It is simply a history of the facts you learned. If you learn today a fact about last year, it still belongs at the end of your event stream, but marked with the relevant dates.
The best way to query this data depends on what kinds of questions you want to answer. There are several nice papers on how to construct temporal and bitemporal database schemas, which would be populated by projectors feeding off your event stream.
Upvotes: 9