I’m designing a domain model where some entities evolve over time, and I need to keep a historical record of their state that can be retrieved later.

A simplified example:

A Credit Line represents a long-term financing contract.

Each Credit Line has related entities such as Financial Entities that participate in the credit line.

The state of a Credit Line at a given date is represented by a Statement, which includes its conditions, participating entities, and their contributions (all of that can change over time).

Statements are periodically uploaded from files, and the application must allow users to view the Credit Line state as of any date.

I can’t use SQL temporal tables because the statement date comes from the uploaded file, not from the database change time.

I’m unsure how to best model and persist these time-dependent entities. Possible approaches:

Option A — Keep only the Snapshots

Persist only `CreditLineSnapshot` (Statements).

Each snapshot contains all attributes of a Credit Line at a given date. No data is repeated.

Disadvantages:

- No persistent `CreditLine` entity: must group snapshots by ID to get the list of credit lines for example.

- All relationship with other entities are duplicated in every snapshot, like the owner of a credit line, even if it does not change over time.

Option B — Persist Entities and Snapshots

Persist both CreditLine and its Statement (which contains a CreditLineSnapshot).

Disadvantages:

- Attributes and data duplication: current state exists in both the entity and its last statement (as all statements should be saved)

Option C — Persist Entities with stable attributes + Snapshots with variable data

Persist `CreditLine` with only stable attributes (e.g. Id), and store all variable data in its `Statements`.

Credit Line contains all methods but just ID attribute and its statements. It delegates in the proper statement to get the rest of the data and make all the calculus.

This is my favorite option.

What’s the best modeling strategy or common practice for this kind of domains, where entities have evolving state over time but must also keep historical versions?

2 Replies 2

When designing a domain model for something like a Credit Line that changes over time, a solid approach is to keep a core CreditLine entity with just stable info (like its ID) and store all changing details (conditions, financial entities, contributions) in dated snapshots or Statements. This avoids duplicating static info and keeps complete history, letting you query the state at any date by picking the right snapshot. This matches your Option C and keeps the model clean and easy to maintain.

Another approach is Event Sourcing, where you store every change as an immutable event and rebuild the Credit Line’s state by replaying those events. This offers a detailed audit trail and no data duplication but adds complexity in querying and implementation.

For your case, Option C is usually simpler and practical unless you need fine-grained change tracking that Event Sourcing provides. Both are established patterns for managing evolving, versioned domain data.

Thanks! A follow-up question:

If the CreditLine (or Financing) entity only holds stable attributes like the ID, would it also contain a list of its Snapshots?

Should getters and all domain logic (like calculations) stay in the CreditLine class and delegate to the latest snapshot, or live directly in the Snapshot and the Credit Line class just have methods to add and retrieve a snapshot?

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.