InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Bitemporal Framework Adds Time Dimension To Rich Domain Models

Posted by Srini Penchikala on Jan 15, 2008

Sections
Development
Topics
Java

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.

 

Srini Penchikala currently works as Security Architect and has 17 yrs of experience in software product management.

Project status clarification by Erwin Vervaet Posted
  1. Back to top

    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.

Educational Content

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.