title: What's a good way to provide versioned rows in PostgreSQL? How to query them?
body: <p>I want to store different versions of different texts and other data in a table. For the texts, my table looks like this:</p>
  
  <pre><code>id BigSerial, PRIMARY KEY  
  version Integer  
  text Text  
  origin BigInt
  </code></pre>
  
  <p>Now I want to store different versions of texts in this table like this:</p>
  
  <pre><code>1,0,"My Text, first Version",null  
  2,1,"My Text, second Version",1  
  3,0,"My 2nd Text v1",null  
  4,1,"My 2nd Text v2",3
  </code></pre>
  
  <p>I don't know yet how to query for the row with the highest version number for each set of texts.</p>