title: Database Design for Revisions?
body: <p>We have a requirement in project to store all the revisions(Change History) for the entities in the database. Currently we have 2 designed proposals for this:</p>
  
  <p>e.g. for "Employee" Entity</p>
  
  <p><strong>Design 1:</strong></p>
  
  <pre><code>-- Holds Employee Entity
  "Employees (EmployeeId, FirstName, LastName, DepartmentId, .., ..)"
  
  -- Holds the Employee Revisions in Xml. The RevisionXML will contain
  -- all data of that particular EmployeeId
  "EmployeeHistories (EmployeeId, DateModified, RevisionXML)"
  </code></pre>
  
  <p><strong>Design 2:</strong></p>
  
  <pre><code>-- Holds Employee Entity
  "Employees (EmployeeId, FirstName, LastName, DepartmentId, .., ..)"
  
  -- In this approach we have basically duplicated all the fields on Employees 
  -- in the EmployeeHistories and storing the revision data.
  "EmployeeHistories (EmployeeId, RevisionId, DateModified, FirstName, 
        LastName, DepartmentId, .., ..)"
  </code></pre>
  
  <p>Is there any other way of doing this thing? </p>
  
  <p>The problem with the "Design 1" is that we have to parse XML each time when you need to access data. This will slow the process and also add some limitations like we cannot add joins on the revisions data fields.</p>
  
  <p>And the problem with the "Design 2" is that we have to duplicate each and every field on all entities (We have around 70-80 entities for which we want to maintain revisions).</p>