title: SQL - Tuple as Primary Key
body: <p>How would you create a primary key out of a tuple from a table?</p>
  
  <p>Example -</p>
  
  <pre><code>table a: [id|name]
  table b: [id|name]
  table axb:[a_id|b_id]
  </code></pre>
  
  <p>Now we want to add a primary key to axb so that the tuple {alpha, beta} is unique. In other words, the table can't contain the rows (alpha, beta) and (beta, alpha). This would extend to ntuples but I'm asking about couples to start to keep this simple.</p>
  
  <p>I'm working with MySql 14.14/5.5.50 - but I'm hoping that doesn't matter.</p>
  
  <p>Note that a composite key doesn't solve this as a composite key on a_id/b_id would still allow the row with inverse tuple order as a new row</p>