InfoQ

News

Bitemporal Framework Adds Time Dimension To Rich Domain Models

Posted by Srini Penchikala on Jan 15, 2008 02:00 PM

Community
Java
Topics

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.

 

1 comment

Reply

Project status clarification by Erwin Vervaet Posted Jan 16, 2008 2:34 PM
  1. Back to top

    Project status clarification

    Jan 16, 2008 2:34 PM 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.

Exclusive Content

Typemock: Past, Present and Future

Eli Lopian of Typemock answers a few questions on Typemock origins and where Typemock is headed.

Agile in Practice: What Is Actually Going On Out There?

Scott Ambler talks about actual data resulting from surveys made during 2006-2008, showing how Agile is perceived and implemented within organizations.

Building Smart Windows Applications

From QCon 2008, Daniel Moth presents on using Visual Studio 2008 and .NET 3.5 to create compelling rich Windows applications.

Joshua Kerievsky about Industrial XP

Joshua Kerievsky, founder of Industrial Logic, talks about Industrial Extreme Programming which extends XP by including practices dealing with management, customers and developers.

Jeff Barr Discusses Amazon Web Services

Amazon Web Services (AWS) Evangelist Jeff Barr discusses SimpleDB, S3, EC2, SQS, cloud computing, how different Amazon services interact, origins of AWS, AWS globalization and the March AWS outage.

More Than Just Spin (Up) : Virtualization for the Enterprise and SaaS

Cloud services have helped bring virtualization to the forefront. Its full power however, also includes other benefits such as high availability, disaster recovery, and rapid provisioning.

Ruby Beyond Rails

John Lam talks about his path to dynamic languages, some of the problems of making IronRuby run fast, and how the DLR helps with implementing languages.

VMware Infrastructure 3 Book Excerpt and Author Interview

VMware Infrastructure 3: Advanced Technical Design Guide and Advanced Operations Guide provides a wealth of practical insights into setting up virtualization in todays corporate environments.