BT

Bitemporal Framework Adds Time Dimension To Rich Domain Models

| by Srini Penchikala Follow 36 Followers on Jan 15, 2008. Estimated reading time: 2 minutes |

Tracking time is a very common requirement in business domain models. Whether it's the history of stock market data in a financial application or tracking the lifecycle of a loan in a mortgage lending system, temporal data management is an important part of the design in the enterprise applications.

Bitemporal framework from ErvaCon is an open source project created based on the Temporal Patterns to address the time related data requirements in rich domain models. This framework was discussed in a recent presentation by Erwin Vervaet at SpringExperience conference. Bitemporal can be used to persist core domain objects and their bitemporal properties (such as Address, Name, Social Status that don't change too frequently) in a relational database like Oracle using an Object Relational Mapping (ORM) framework such as Hibernate.

In the presentation, Erwin explained three different ways of managing the temporal data in an application:

  • Non-temporal: No time tracking is supported in the system and the data can only answer questions about the current situation. Relational databases such as Oracle or Microsoft SQL Server are non-temporal.
  • Single-temporal: This has two variants called actual-temporal and record-temporal. Actual-temporal adds a validity interval to track when a fact is valid in actual time. Record-temporal adds a record interval to track when a fact was recorded in the system. This provides a way to answer questions about what was known about a domain object at a certain point in time.
  • Bi-temporal: This design approach combines actual-temporal and record-temporal change tracking concepts. It allows the system to answer questions about what was known at a certain point in time about a fact at another moment. This design is more complex than the other two options since the system will have to track two time intervals.

Erwin discussed the design options for implementing bi-temporality in domain models by using a Temporal Database or writing custom code. A Temporal Database supports the time aspects like temporal data model and temporal version of SQL. TimeDB is an open-source temporal relational database product. Oracle FlashBack is another temporal database product that supports the record-temporal feature. Using Flashback, the DBAs can restore a table or an entire database to a point in the past using a simple SQL statement with FLASHBACK keyword. FLASHBACK TABLE statement reads the past images of the table from the undo segments and reconstructs the table rows using the flashback queries.

Regarding the custom code, the implementation technique for adding time information to a database is to add four additional columns in the tables (validityFrom, validityTo, recordFrom, and recordTo columns). Speaking of temporal based system design, Erwin listed the following as the key facets of temporal change tracking:

  • Identity
  • Immutability (Temporal properties are immutable in the sense that changing the value results in a new value being added to the properties history).
  • Validity & Recording time details
  • Controlling time

Temporal patterns are not a new concept in the application architecture and design. Martin Fowler documented these patterns on his "Patterns of Enterprise Application Architecture" (PoEAA) website. Temporal Patterns section on the website includes the patterns such as Audit Log, Effectivity, Temporal Property, Temporal Object, and Snapshot.

The key interfaces and classes in Bi-temporal framework are BitemporalTrace, Bitemporal, BitemporalProperty, WrappedBitemporalProperty, BitemporalWrapper, and TimeUtils. The framework uses Joda Time API for handling the date time manipulation logic. The source code of the project is available for download from their Subversion repository.

 

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Project status clarification by Erwin Vervaet

Thank you for the nice write-up!

Just to clarify things: the 'Bitemporal' source code is available under an open source license (BSD), but is at the moment not actively maintained as a an open source project. To quote from the readme:

At this moment, this code is not part of a real project, and as such it is not activly worked on or developed. Still, it provides a good starting point for those that need to tackle temporal issues in their applications.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT