title: Postgres on conflict do update on composite primary keys
body: <p>I have a table where a user answers to a question. The rules are that the user can answer to many questions or many users can answer one question BUT a user can answer to a particular question only once. If the user answers to the question again, it should simply replace the old one. Generally the on conflict do update works when we are dealing with unique columns. In this scenario the columns <code>person_id</code> and <code>question_id</code> cannot be unique. However the combination of the two is always unique. How do I implement the insert statement that does update on conflict?</p>
  
  <pre><code>CREATE TABLE "answer" (
    "person_id" integer NOT NULL REFERENCES person(id), 
    "question_id" integer NOT NULL REFERENCES question(id) ON DELETE CASCADE, /* INDEXED */
    "answer" character varying (1200) NULL,
    PRIMARY KEY (person_id, question_id) 
  );
  </code></pre>