The Artima Developer Community
Sponsored Link

Java Community News
Tracking Versioned Data: A Database or Subversion?

4 replies on 1 page. Most recent reply: Sep 18, 2006 3:29 PM by Amrinder Arora

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Tracking Versioned Data: A Database or Subversion? Posted: May 8, 2006 8:26 AM
Reply to this message Reply
Summary
Enterprise applications increasingly are required to store the full change history of important business objects. While relational databases are often used to store historic data with triggers or application code, Swaminathan Radhakrishnan argues in an OnJava article that storing object history data is the perfect job for a version control system.
Advertisement

At a talk given at USC a few years ago, Jim Gray mused that inexpensive storage might make the SQL delete and update operators obsolete: Instead of updating a database record, a system could just insert a new version of that record, keeping of continuous version history of database objects.

Gray's main motivation in making that remark was not primarily a desire to store a change history of an object just because we can—due to inexpensive storage—but because storing large amounts of data extremely fast might not be feasable with updates and deletes. (The topic of his talk was working with petabyte databases.)

Recently passed stringent laws about business record keeping are even more important motivators than cheap disks for keeping object version histories. Such change histories must preserve not only how an object changed, but also who and when caused an object to change.

A common method of keeping history records is to create a time-stamped version history table along with a main table for a class of database objects. When an update or delete is initiated on the main table, a database trigger can select the old record and insert it into the history table, along with some metadata identifying the user making the change and a change timestamp.

That approach makes retrieving an object's version history as simple as selecting all history records for an object, and displaying the changes occuring to each field between consecutive records.

In a recent OnJava article, Swaminathan Radhakrishnan suggests that storing versioning data is just the task version control systems are designed for: Version control systems not only store differences between objects, but also metadata associated with change that's useful in a business context. Radhakrishnan goes on to demonstrate how to use the Java Subversion client library, JavaSVN, to store version histories of a business object.

Using a version control system can provide a nice benefit when diffing large text fields, such as the field that stores the text of this news post, for instance. By comparing changes to such text fields as Subversion diffs, graphical diff tools, such as fldiff can be used to illustrate to a user the changes occurring to such text.

The biggest drawback for using a version control system for object histories might be performance. One trick in Radhakrishnan article is that he stores business objects as XML, not as Java objects. While this approach lets one diff object versions using JavaSVN's SVNDiffManager, having to serialize Java classes to XML for every database update might yield sluggish overall performance. By contrast, database triggers alleviate the need to serialize object state and, indeed, keep data entirely within the database server's address space during versioning.

What's your preferred method of storing object version histories? And how do you present version changes to users?


Gregor Zeitlinger

Posts: 108
Nickname: gregor
Registered: Aug, 2005

Re: Tracking Versioned Data: A Database or Subversion? Posted: May 8, 2006 11:43 AM
Reply to this message Reply
I'd say neither of the two.

Almost every database server already stores changes (called transaction log or write ahead log) for recovery and backup purposes.

The only problem with these log files is that they can only be used to restore an old state of the entire database, not separate tables, rows, or columns.

Hence, we'd only need an SQL API to access the log files, which we need for backup purposes anyways.

This way, we would not only have the fastest versioning system (free), but it would also be maintenance-free (we only need to make sure that all log files are saved).

Leo Lipelis

Posts: 111
Nickname: aeoo
Registered: Apr, 2006

Re: Tracking Versioned Data: A Database or Subversion? Posted: May 8, 2006 12:12 PM
Reply to this message Reply
Gregor,

Sounds like a good idea to me. Oracle has something called "a flashback query". I wonder if those flashback queries read log files? Querying log files that are not loaded into tablespaces and indexed and, in general, not optimized for querying, might be slow. Such an API sounds like a good idea even if it's slow to query. For high performance versioning something else might be needed.

Version control software has a concept of branches, and I don't know how that would work with logs. I don't know if business apps need to take advantage of branching histories. If a business app needed to take advantage of branching histories, then using version control system would appear more attractive.

Gregor Zeitlinger

Posts: 108
Nickname: gregor
Registered: Aug, 2005

Re: Tracking Versioned Data: A Database or Subversion? Posted: May 9, 2006 12:37 PM
Reply to this message Reply
> Querying log files that are not
> loaded into tablespaces and indexed and, in general, not
> optimized for querying, might be slow.
Yes. If legal obligations are your concern (as suggested in the article), this will not be a problem.

> Such an API sounds
> like a good idea even if it's slow to query. For high
> performance versioning something else might be needed.
Preferrable, the API would be the same. You would just tell the database that the history of all/some tables should be kept in tablesspaces (with indexes). As those history tables could always be restored from the log files, they would be similar to materialized views.

> Version control software has a concept of branches, and I
> don't know how that would work with logs.
Postgres has a concept of timelines, which are the same as branches (but not as easy to handle). But thats not the point. The point of my original post is that database servers can easily be modified to handle versioning.
And this is cleanest (in terms of ACID) and easiest to use solution.

Amrinder Arora

Posts: 1
Nickname: amrinder
Registered: Sep, 2006

Re: Tracking Versioned Data: A Database or Subversion? Posted: Sep 18, 2006 3:29 PM
Reply to this message Reply
Actually, there is a full product that does exactly this: vAuditServer. More details (datasheet, etc) can be found at www.variaware.com

The previous posters have already identified the main requirements for tracking versioned data:
1. We want access to the old versions of data, not just database logs.
2. We cannot depend on history tables, as the history tables will pollute (destroy?) the original schema. Application logic will become 90% history keeping and 10% business logic.
3. It may be somewhat acceptable for audit trace to be a bit slower than regular business object.
4. Version tracking should be switchable (on/off), and you should be able to add that feature to new business objects that you build. In other words, it should not involve new development for every data object.

vAuditServer meets these 4 criteria.

Regards,
Amrinder

Flat View: This topic has 4 replies on 1 page
Topic: Tracking Versioned Data: A Database or Subversion? Previous Topic   Next Topic Topic: Tangosol's Cameron Purdy on Data Grids

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use