title: SQLite Unique Key with a combination of two columns
body: <p>I'm trying to make sure when I run the following query only the first <code>INSERT INTO</code> will work.. I know I have to make <code>slot</code> <code>UNIQUE</code></p>
  
  <p>The slot could be from 0-5 INTEGER but it doesn't mean that only 6 table data rows could be accepted into that table.</p>
  
  <p>For each playerHash that matches it should only allow 6 table data rows as <code>slot</code> is <code>UNIQUE</code> (cannot have duplicate of same slot column, for each playerHash column).</p>
  
  <pre><code>//Below Query Should Pass
  INSERT INTO Buying(itemId, amount, price, bought, slot, playerHash) VALUES (1, 1, 1, 1, 1, 1);
  //Below Query Should Fail
  INSERT INTO Buying(itemId, amount, price, bought, slot, playerHash) VALUES (1, 1, 1, 1, 1, 1);
  //Below Query Should Pass
  INSERT INTO Buying(itemId, amount, price, bought, slot, playerHash) VALUES (1, 1, 1, 1, 1, 2);
  //Below Query Should Fail
  INSERT INTO Buying(itemId, amount, price, bought, slot, playerHash) VALUES (1, 1, 1, 1, 1, 2);
  //Below Query Should Pass
  INSERT INTO Buying(itemId, amount, price, bought, slot, playerHash) VALUES (1, 1, 1, 1, 0, 2);
  </code></pre>
  
  <p>Problem of course is they all pass and cause duplicate entries</p>
  
  <p>Currently I use this table DDL</p>
  
  <pre><code>CREATE TABLE Buying ( 
      id         INTEGER PRIMARY KEY AUTOINCREMENT,
      itemId     INTEGER NOT NULL,
      amount     INTEGER NOT NULL,
      price      INTEGER NOT NULL,
      bought     INTEGER NOT NULL,
      collected  INTEGER NOT NULL
                         DEFAULT ( 0 ),
      overpaid   INTEGER NOT NULL
                         DEFAULT ( 0 ),
      slot       INTEGER NOT NULL,
      aborted    BOOLEAN NOT NULL
                         DEFAULT ( 0 ),
      playerHash INTEGER NOT NULL 
  );
  </code></pre>