History of objects?  
Author Message
Peter Kirk





PostPosted: 2005-1-7 18:10:00 Top

java-programmer, History of objects? Hi

a relatively complex project I am working on now has a need for
"versioning". I mean, we have a system for administration of data (creating
and updating) in a database, and this data needs to be saved as separate
versions each time it is updated - a lot like a CVS.

The data is in the main "bridges", which have lots of data (name, location,
height etc), and lots of related data: persons (controller, supervisor);
tasks to be performed...

It should for example be possible for a user to view a "bridge" as it looked
on a certain date in the past, with all its related data (as they also were
at that date).

Does anyone have some good ideas about how we can save a history of versions
of all our objects? Where can I start to look for good ideas? Could we use
CVS via some sort of java api?


Thanks,
Peter

 
Chris





PostPosted: 2005-1-8 0:43:00 Top

java-programmer >> History of objects? > a relatively complex project I am working on now has a need for
> "versioning". I mean, we have a system for administration of data
(creating
> and updating) in a database, and this data needs to be saved as separate
> versions each time it is updated - a lot like a CVS.
>
<snip>
> Does anyone have some good ideas about how we can save a history of
versions
> of all our objects? Where can I start to look for good ideas? Could we use
> CVS via some sort of java api?

I presume you're using a SQL database. I've handled this in the past by
having a set of history tables that parallel my app's tables. For example,

table bridge (id, name, location)
table bridge_history (id, version#, user_id, timestamp, name, location)

Make the primary key of the history table the id + the version #. The
user_id tells you who made the change, and the timestamp tells you when it
happened.

If your database is not large, it's easiest just to create a complete
snapshot of the record in the history table. If saving space is important,
then just save the *old* values of the fields that changed. That's a lot
more work, though, if you want to recreate a snapshot of the data at a given
point in time.