Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A technique I've used for this in that past has been to have a concept of "generations" in the database, each change increments the current generation number for the database - if you use subversion, think revisions. Each record has 2 generation numbers associated with it (2 extra columns on the tables) - the generation that the record starts being valid for, and the generation the it stops being valid for. If the data is currently valid, the second number would be NULL or some other generic marker.</p> <p>So to insert into the database:</p> <ol> <li>increment the generation number</li> <li>insert the data</li> <li>tag the lifetime of that data with valid from, and a valid to of NULL</li> </ol> <p>If you're updating some data:</p> <ol> <li>mark all data that's about to be modified as valid to the current generation number</li> <li>increment the generation number</li> <li>insert the new data with the current generation number</li> </ol> <p>deleting is just a matter of marking the data as terminating at the current generation.</p> <p>To get a particular version of the data, find what generation you're after and look for data valid between those generation versions.</p> <p>Example:</p> <p>Create a person.</p> <pre><code>|Name|D.O.B |Telephone|From|To | |Fred|1 april|555-29384|1 |NULL| </code></pre> <p>Update tel no.</p> <pre><code>|Name|D.O.B |Telephone|From|To | |Fred|1 april|555-29384|1 |1 | |Fred|1 april|555-43534|2 |NULL| </code></pre> <p>Delete fred:</p> <pre><code>|Name|D.O.B |Telephone|From|To | |Fred|1 april|555-29384|1 |1 | |Fred|1 april|555-43534|2 |2 | </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload