title: PostgreSQL Unique index compound key
body: <p>I need to create a restriction on a table based on four columns, and two of them are mutually exclusive, I mean, if one is NULL the other is not.</p>
  
  <p>The ideal script would be this:</p>
  
  <pre><code>ALTER TABLE ONLY t_users_prizes
  ADD CONSTRAINT t_user_prize_test_circuit_key
  UNIQUE (id_event||':'||id_circuit, id_prize, id_user);
  </code></pre>
  
  <p>But Postgres doesn't allow this kind of concatenation.</p>
  
  <p>How can I implement this restriction?</p>