Hi,
Thanks for the answer again.
I understand your warning, and yet I think I'll go with design close to that.
I have several related entity (I'm not saying tables - I'll get to that). I want to preserve the history of each entity - but not only by itself but also as whole to others. Meaning I will be able to put all changes on a timeline (one timeline) and see the changes.
Also I need to be able to work online with the history - not only manual revert to previous version but also selecting in the UI an entity with previous version and compare the current version with the old one.
It will create something like svn - single version numerator to all repository.
I understand that I will not be able to use foreign keys as regular database but than again it is not a regular database - it is temporal database implemented over relational database.
Since my version numerator is the single most unique thing across the database I'll also use it as primary key for each table - meaning the real primary key (which will not be unique in the table) will not be marked as primary key.
This is the key issue why ebean and other ORM are not well suited for this database design.
Let me expand that - if I have a student and classroom database - each student belong to single classroom.
First I add eddy(id=1,v=1) to student table. Then I add ClassA(id=1,v=2) to classroom. Now I assign eddy to ClassA which make new copy of eddy(id=1,v=3,class=1).
If I now select students and class in version 3 I get ClassA(v=2) with eddy(v=3).
Now, if I update eddy's name to eddy rock(id=1,v=4) I only update student table without touching classroom table - but now if I select version 4 I'll get new eddy's name, if I select version 3 I'll get the old eddy's name.
So foreign keys are still only column, now composed, and also I can update each table by itself without go over all other tables and update the referenced version.
The down side is that selecting the data become harder.
What do you think? :)
Thanks.