Erlang/OTP Forums

Author Message

<  Open Telecom Platform (OTP)  ~  temporal mnesia

dsmith
Posted: Mon Feb 04, 2008 12:02 pm Reply with quote
User Joined: 08 Aug 2007 Posts: 41 Location: Toronto
Is there an application that provides a temporal DB management layer on top of mnesia. Supporting valid-time and transaction-time intervals as well as read/write/delete functions to manipulate them should be fairly easy.

Does anyone know if there has been any contribution like this?

This may not have a lot of uses for soft real-time system for which mnesia was created, but I thought Id ask if there might be interest in such an application.
View user's profile Send private message
dsmith
Posted: Mon Feb 04, 2008 12:15 pm Reply with quote
User Joined: 08 Aug 2007 Posts: 41 Location: Toronto
Where I'm coming from is this...

I write business applications and am looking at Erlang as as possible framework language. Whereas valid-time state management may not have many uses in soft real-time systems, they are central to business applications. (And transaction-time state management is central to auditing)

I recognize mnesia would not be appropriate for storing business records of the type that would benefit from VT state management. However, I do find mnesia an exceptional tool for prototyping business applications. Providing temporal management would make it even easier.
View user's profile Send private message
francesco
Posted: Tue Feb 05, 2008 7:37 pm Reply with quote
User Joined: 07 Jul 2006 Posts: 249 Location: London
Hi,

I have never heard of anyone writing a temporal DB management layer/application for Mnesia. What would the requirements be? Using time stamps generated from now() when entering the data and ordered sets might be a step in the right direction.

Francesco
--
http://www.erlang-consulting.com
View user's profile Send private message Visit poster's website
dsmith
Posted: Wed Feb 06, 2008 6:13 am Reply with quote
User Joined: 08 Aug 2007 Posts: 41 Location: Toronto
That's still unclear -- what does the underlying mnesia table look like?

I envision an interface that is a subset of the mnesia interface with a create_table that transforms the TabDef arguments to mnesia arguments.

So there would be a exported function:
tmnesia:create_table(Name, TabDef)
where TabDef is defined the same as mnesia except that the {type, Type} argument is one of vtime, ttime, or bitemporal.

This function would transform the list argument and call the mnesia:create_table/2 with a type of set, ordered_set, or bag. In any case temporal integrity and continuity would have to be ensured by the library. It could be done with a bag, keeping a time intervals outside of the key, but some queries may perform poorly if a large number of time-state changes are recorded for one key.

My feeling that an ordered_set where the Key is transformed to {TTInterval, VTInterval, Key} would be best. Where the interval() -> {TEnd, TStart} and the TEnd and TStart are probably not date() as defined in stdlib. The most common queries would benefit from ordering in reverse time order so that the most recent is first. (ie. a query for the currently valid record in the current trans-state is very common.)

I would add Key as an secondary attribute as well and apply an index to it to improve other queries.

Some of the most common queries would look like this:
Code:

tmnesia:read(current, {Tab, Key}).
tmnesia:read({valid, VDate}, {Tab, Key}).
tmnesia:read({valid, VInterval}, {Tab, key}).
tmnesia:read(valid, {Tab, key}).
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum