title: PostgreSQL: NULL value in foreign key column
body: <p>In my PostgreSQL database I have the following tables (simplified):</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE quotations (
    receipt_id bigint NOT NULL PRIMARY KEY
  );
  
  CREATE TABLE order_confirmations (
    receipt_id bigint NOT NULL PRIMARY KEY
    fk_quotation_receipt_id bigint REFERENCES quotations (receipt_id)
  );
  </code></pre>
  <p>My problem now reads as follows:</p>
  <p>I have orders which relate to previous quotations (which is fine 'cause I can attach such an order to the quotation referenced by using the FK field), but I also have placed-from-scratch orders <strong>without</strong> a matching quotation. The FK field would then be NULL, if the database let me, of course. Unfortunately, I get an <strong>error</strong> when trying to set <code>fk_quotation_receipt_id</code> to NULL in an INSERT statement because of a <strong>violated</strong> foreign key constraint.</p>
  <p>When designing these tables I was still using PgSQL 8.2, which allowed NULL values. Now I've got 9.1.6, which does not allow for this.</p>
  <p>What I wish is an <strong>optional (or nullable)</strong> foreign key constraint <code>order_confirmations</code> (<code>fk_quotation_receipt_id</code>) → <code>quotations (receipt_id)</code>. I can't find any hints in the official PgSQL docs, and similar issues posted by other users are already quite old.</p>
  <p>Thank you for any useful hints.</p>