Current Rows and Historical Events

A current row can record the latest state. An event table can retain selected transitions when the history itself matters.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace an article state
  2. Keep the event identity
  3. Answer the same question from two storage models
  4. Define how the two representations stay consistent

Trace an article state

A draft can become published and later archived. The current status is archived, while two meaningful transitions remain available in history. See reducing events to state.

Keep the event identity

If events are processed more than once, use distinct IDs and a deliberate repeat policy. Handling duplicate events explains why two deliveries can still describe one action.[1][2]

Answer the same question from two storage models

A ticket currently marked closed cannot show by that field alone when it was reopened. A separate event history can record created, closed, reopened and closed transitions with their sequence. A table of current state can still serve fast reads. See sequences of events.

Current row: ID 42, closed
Event stream: created → closed → reopened → closed
One current row and four historical observations serve distinct queries

Define how the two representations stay consistent

If history is required for every state change, persist event and state together under the stated guarantee or derive state from ordered events. Test a failed write and a retry without duplicating a transition.

References

  1. PostgreSQL Global Development Group, Data Definition ↩
  2. PostgreSQL Global Development Group, SQL Language Tutorial ↩