title: Postgres unique combination constraint across tables
body: <p>I have three tables -</p>
  
  <pre><code>file (
    file_id int primary key
    filename text not null
    etc...
  )
  product (
    product_id int primary key
    etc....
  )
  product_attachment (
    product_id references product
    file_id references file
  )
  </code></pre>
  
  <p>I want to ensure that when these are natural-joined, product_id + filename is unique.
  The best solution I have so far involves adding filename to the product_attachment table, but I'm wondering if there's a way to avoid that.</p>