title: Postgres key-value table, select values as columns
body: <p>I have the following table:</p>
  
  <pre><code>+----+---------+-------+
  | id |  Key    | Value |
  +----+---------+-------+
  |  1 | name    | Bob   |
  |  1 | surname | Test  |
  |  1 | car     | Tesla |
  |  2 | name    | Mark  |
  |  2 | cat     | Bobby |
  +----+---------+-------+
  </code></pre>
  
  <p><code>Key</code> can hold basically anything. I would like to arrive at the following output:</p>
  
  <pre><code>+----+------+---------+-------+-------+
  | id | name | surname |  car  |  cat  |
  +----+------+---------+-------+-------+
  |  1 | Bob  |  Test   | Tesla |       |
  |  2 | Mark |         |       | Bobby |
  +----+------+---------+-------+-------+
  </code></pre>
  
  <p>Then I would like to merge the output with another table (based on the <code>id</code>).</p>
  
  <p>Is it possible to do, if I don't know what the <code>Key</code> column holds? Values there are dynamic.
  Could you point me to the right direction?</p>