title: What versioning design pattern would you recommend
body: <p>I have a requirement to build 'versioning' into an application and was wondering how best to approach it. </p>
  
  <p>I have this general pattern:</p>
  
  <p>Model A has many B's</p>
  
  <p>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.</p>
  
  <p>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. </p>
  
  <p>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?</p>
  
  <p>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). </p>
  
  <p>Update: What I was thinking/have implemented but want to see if the is "a better way"</p>
  
  <pre><code>,---------. 1      * ,--------.
  | Model A |----------| Model B|
  `---------'          `--------'
  |PK       |          | a_id   |
  |b_version|          |version |
  |version  |          `--------'
  `---------'
  </code></pre>
  
  <p>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.</p>