I have some idea but I need a sponsor to implement it.

2009/5/13 Will Holley <[email protected]>

>
> We are currently using NHibernate to store historical versions of
> entities. The schema we currently use has 2 tables for each entity
> (one containing only the most recent version and one containing all
> the historical ones). A critical element to this mechanism is that we
> need to be able to rehydrate an entity including its associated
> entities for a specific version.
>
> To illustrate using a trivial case with pseudo ActiveRecord, lets say
> you have:
>
> class Person
> {
>      [BelongsTo(Cascade = CascadeEnum.All)]
>      Address PrimaryAddress { get; set; }
> }
>
> class Address
> {
>      [HasMany(Inverse = true)]
>      IList<Person> Persons
>
>      ....
> }
>
>
> When a Person is saved, historical entries for the Person and the
> associated Address would be generated so that when you get the
> historical Address you can see the Persons associated with it at that
> revision. You then also have to create historical entries for all the
> other Persons associated with the Address. Hopefully the sequence
> below illustrates this:
>
> 1. create first Person P1:
>
>     A1 @1                                            History(A1)
> @1
>   /                generates ->                     /
> P1 @1                                         History(P1) @1
>
> 2. create second Person P2:
>
>    A1 @1                                        History(A1)
> @2
>   /                generates ->                /               \
> P2 @1                           History(P1) @2          History(P2) @1
>
> 3. update first Person P1:
>
>  A1 @1                                        History(A1) @3
>  /               generates ->                 /                \
> P1 @ 2                        History(P1) @3             History(P2)
> @2
>
>
> Despite the potential for an explosion in complexity, this approach is
> working reasonably well for our specific use case. However, there are
> significant problems in terms of a general solution. Specifically:
>
> 1. You are generating a large amount of redundant data because you
> create historical entries when the data hasn't changed (in this
> example you would create an historical Address for each change to
> Person even though the data in the Address entity has not changed).
>
> 2. You have to fetch the complete graph of related entities in order
> to do a trivial save / update - an obvious performance killer.
>
> I have seen a lot of blog posts / group discussions about how people
> deal with storing old revisions of one entity but I have not seen
> anything discussing this problem of rehydrating complete historical
> object graphs (maybe nobody else is crazy enough to do this?). I
> cannot seem to find any precedent with other ORMs either (maybe I'm
> missing the Google incantation?).
>
> One idea we've had is that maybe it would be possible to version the
> relationships between entities as well as the entities themselves.
> This way we would not need to generate redundant rows when the data
> itself hasn't changed (as in the example case).
>
> Has anybody else done anything like this or have any thoughts on where
> to research this problem?
>
> Many thanks,
>
> Will Holley
>
> >
>


-- 
Fabio Maulo

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to