← Back to Learn
ELEMENTARY PATTERN

Event Modeling

Records business changes as immutable facts so historical state can be reconstructed, audited and projected consistently.

A reliable event model preserves what happened, when it became effective, when it was recorded and how simultaneous events are ordered.

Problem

Current-state rows explain what is true now, but not how the entity reached that state.

Updating one row in place removes the sequence of business changes that created the current value. Later, teams cannot reliably explain when a contract was created, changed or cancelled.

Event Modeling stores each meaningful business occurrence as an immutable event. The ordered event stream becomes the historical source from which state, timelines and analytical projections can be derived.

This only works when event identity, temporal meaning and ordering are explicit. Otherwise replay can produce different states from the same data.

Lost change historyAmbiguous replayDuplicate eventsUnstable state projections
Example

An ordered contract event stream is replayed into one deterministic historical state timeline.

Event stream ←’ state projection
Immutable business eventsCREATEDJan 05PREMIUMApr 10CANCELLEDSep 20Deterministic state projectionDraftActive · premium 120CancelledJan 05 – Apr 09Apr 10 – Sep 19Sep 20 onwardSame events + same ordering contract = same historical state timeline
Key rule

Events are not states. They describe transitions. The projection must apply every event exactly once in a deterministic order and reject impossible or ambiguous transitions.

Core concepts

A trustworthy event stream separates identity, time and order.

Event identity
A stable event_id makes ingestion idempotent and duplicates detectable.
Effective time
When the business event belongs in the historical timeline.
Recorded time
When the platform first knew or stored the event.
Ordering
A deterministic contract resolves simultaneous or late-arriving events.
Transition rules
The preceding state determines whether an event is valid.
Replay
Reprocessing the same stream must produce the same projection.
Test case

Analyze this Event Modeling example

Use these sample event streams to test deterministic replay:

  1. Choose one event stream below.
  2. Start an investigation with the selected example.
  3. Review identity, temporal semantics and event ordering.
  4. Check whether replay yields one intended historical timeline.
Deterministic event stream

All events have stable identity and an explicit sequence.

event_id,aggregate_id,business_key,event_type,sequence
E1,A1,C-1001,Created,1
E2,A1,C-1001,PremiumChanged,2
E3,A1,C-1001,Deleted,3
Ambiguous event stream

Two simultaneous events have no stable priority or sequence.

event_id,aggregate_id,business_key,event_type,sequence
E1,A1,C-1001,Created,1
E2,A1,C-1001,PremiumChanged,2
E2,A1,C-1001,PremiumChanged,3
E3,A1,C-1001,Activated,4
The model

Events describe transitions; projections derive reportable state.

Each event represents a business fact such as contract creation, a premium change or cancellation. It should have a stable identifier and belong to exactly one business entity.

entity_id | event_type         | effective_at
C-1001    | CONTRACT_CREATED   | 2024-01-05
C-1001    | PREMIUM_CHANGED    | 2024-04-10
C-1001    | CONTRACT_CANCELLED | 2024-09-20
Keep time meanings separate
effective_at describes when the event belongs in business history. recorded_at describes when the platform learned about it. Conflating them destroys reliable handling of late-arriving corrections.
Deterministic ordering

Every replay must resolve events in one stable order.

Timestamps alone are often insufficient. Two events may share the same effective and recorded timestamp, particularly after batch ingestion or backfill.

order by
  effective_at,
  recorded_at,
  event_priority,
  event_sequence,
  event_id

The exact ordering contract can differ, but it must be explicit, stable and covered by tests. A physical input order is never a valid historical rule.

Why it happens

Event streams become unreliable when ingestion mechanics leak into business semantics.

Retries can create duplicates. Batch loads can assign identical timestamps. Late-arriving events can be recorded after later business events. Source systems may emit technical messages that are not independent business facts.

A robust model normalizes those conditions without rewriting historical facts. It defines stable event identity, idempotent ingestion, explicit priority and a reproducible projection rule.

Late-arriving eventsRetry duplicatesTimestamp tiesOut-of-order ingestionCorrection eventsProjection drift
Validation checks

Validate the stream before trusting any derived state.

✓ Every event has a stable unique identity✓ Duplicate ingestion is idempotent✓ Effective and recorded time are not conflated✓ Simultaneous events have a deterministic tie-breaker✓ Every transition is allowed from the preceding state✓ Replaying the stream produces the same state every time✓ Late-arriving events preserve prior recorded history
When to use it

Event Modeling is strongest when the business cares about transitions and auditability.

Good fit
✓ Business actions are meaningful facts
✓ Reconstruction and audit matter
✓ Derived state can be replayed
✓ Late arrivals must remain traceable
✓ Multiple projections consume the same history
Use caution
• Only the latest value is meaningful
• Source events are incomplete or unstable
• Ordering cannot be defined
• Events are technical logs without business semantics
• Reporting requires simple state access only
Why it matters

A deterministic event stream preserves explanation, not merely history.

A state table can answer what was valid on a date. An event stream can additionally explain which business facts produced that state.

When event identity, time and ordering are reliable, teams can replay history, rebuild projections, investigate corrections and prove why a report changed.

RELATED TEMPORAL MODELS

How Event Modeling relates to other historical patterns

State Modeling
Stores reportable validity intervals directly. Event projections often produce state histories for efficient queries.
Event-to-State Projection
Transforms ordered events into non-overlapping state intervals with explicit transition rules.
Bitemporal Modeling
Adds recorded-time history so late-arriving events and corrections remain reproducible.
Historical Backfill
Introduces older business events later and requires deterministic replay without corrupting prior outputs.
Related Patterns
State ModelingState ←” Event AlignmentEvent-to-State ProjectionBitemporal ModelingHistorical BackfillSnapshot Reproducibility
Try it

Design or review an event-based historical model.

Describe the event stream or existing implementation. The Historical Data Assistant will guide you through identity, ordering, temporal semantics and state projection.

Open Historical Data Assistant ←’