title: Can INSERT [...] ON CONFLICT be used for foreign key violations?
body: <p>Given</p>
  
  <pre><code>=&gt; select * from referenced;
   referenced_id | name  
  ---------------+-------
               1 | one
               2 | two
               3 | three
  </code></pre>
  
  <p>and</p>
  
  <pre><code>=&gt; select * from entries;
   entry_id | referenced_id |      name      
  ----------+---------------+------------------
          1 |             3 | references three
  </code></pre>
  
  <p>where <code>referenced_id</code> and <code>entry_id</code> are primary keys.</p>
  
  <p>I want an insert statement for <code>entries</code> that skips insertion if either the <code>entry_id</code> already exists or the referenced item does not exist. The first is easily done:</p>
  
  <pre><code>INSERT INTO entries
  VALUES (1, 2, 'references two')
  ON CONFLICT (entry_id) DO NOTHING;
  </code></pre>
  
  <p>Is it possible to check for the existence of the foreign key here too?</p>