I have a requirement to build 'versioning' into an application and was wondering how best to approach it.
I have this general pattern:
Model A has many B's
Where on update the attributes of A need to be versioned and its associated objects (B's) also need to be versioned. So the application will display the current version of A, but it must also be possible to view previous versions of A and its associated objects.
I would like to use a document store however this is only a portion of the application and having a doc store and a relation database would introduce more complexity.
I have considered using a star schema, but before I progress I was wondering if there is a design pattern floating around tackling this problem?
This question is slanted towards resolving the issue of storing the versions of an associated object in a relational database. Where there is an inherent need to be able to effectively query the data (ie serializing object won't suffice).
Update: What I was thinking/have implemented but want to see if the is "a better way"
,---------. 1 * ,--------.
| Model A |----------| Model B|
`---------' `--------'
|PK | | a_id |
|b_version| |version |
|version | `--------'
`---------'
Where I would be duplicating model A and all the associated B's and incrementing the version attribute. Then doing a select to join the B's via b_version and b.version. Just wondering if this can be done better.