title: postgres add constraint to ensure one column is not null if another column is not null
body: <p>Postgres 9.3</p>
  
  <p>I have two integer type columns 'a' and 'b'. Valid options are:</p>
  
  <ul>
  <li>'a' is null, 'b' is null</li>
  <li>'a' is not null, 'b' is null</li>
  <li>'a' is not null, 'b' is not null</li>
  </ul>
  
  <p>I'm trying to add a check/constraint which prevents the invalid option:</p>
  
  <ul>
  <li>'a' is null, 'b' is not null</li>
  </ul>
  
  <p>I'd be grateful for any help.</p>
  
  <p>Thanks in advance
  Dan</p>