title: SQL : table relationship depends on column value
body: <p>I am novice at SQL using Postgres, and have been looking for this answer for a few days.</p>
  <p>I have a table called identification</p>
  <pre><code>| id | name | type |
  </code></pre>
  <p>A type is a driving licence, passport, national id card etc.</p>
  <p>If the type is a driving licence, the relationship should be with the driving licence table</p>
  <pre><code>| id | first_name | last_name | driving_licence_number |
  </code></pre>
  <p>If the type is passport, the relationship should be with the passport_table.</p>
  <p>The way I can describe it in pseudo code is</p>
  <pre><code>if (type == 0) join with driving licence table
  
  if (type == 1) join with passport table etc.
  </code></pre>
  <p>What would be the best way to model this, so I can easily query the identification table, and retrieve the correct info?</p>