title: PostgreSQL Foreign Key with a condition
body: <p>Using postgres sql,  is there a way to set up a condition on foreign key where it's limited to to another table like a normal foreign key constraint, but also allows the value of 0 to exist without it being in the other table. For example:</p>
  
  <pre><code>table_a:
    id
  
  table_b:
    id
    foreign_key_on_table_a_id
  </code></pre>
  
  <p>table_a would have a list of things, and table_b relates to table_a, but has the foreign key constraint. I would also like it to allow for a value of 0 even though there is no id of 0 in table_a. </p>
  
  <p>Is this the right constraint to use? Is there another/better way of doing this without adding the value into table_a?</p>