title: query for a set in a relational database
body: <p>I would like to query a relational database if a set of items exists.</p>
  
  <p>The data I am modeling are of the following form:</p>
  
  <pre><code>key1 = [ item1, item3, item5 ]
  key2 = [ item2, item7 ]
  key3 = [ item2, item3, item4, item5 ]
  ...
  </code></pre>
  
  <p>I am storing them in a table with the following schema</p>
  
  <pre><code>CREATE TABLE sets (key INTEGER, item INTEGER);
  </code></pre>
  
  <p>So for example, the following insert statements would insert the above three sets.</p>
  
  <pre><code>INSERT INTO sets VALUES ( key1, item1 );
  INSERT INTO sets VALUES ( key1, item3 );
  INSERT INTO sets VALUES ( key1, item5 );
  INSERT INTO sets VALUES ( key2, item2 );
  INSERT INTO sets VALUES ( key2, item7 );
  INSERT INTO sets VALUES ( key3, item2 );
  INSERT INTO sets VALUES ( key3, item3 );
  INSERT INTO sets VALUES ( key3, item4 );
  INSERT INTO sets VALUES ( key3, item5 );
  </code></pre>
  
  <p>Given a set of items, I would like the key associated with the set if it is stored in the table and NULL if it is not.  Is it possible to do this with an sql query?  If so, please provide details.  </p>
  
  <p>Details that may be relevant:</p>
  
  <ul>
  <li>I am primarily interested in the database design / query strategy, though I will eventually implement this in  MySQL and preform the query from with in python using the mysql-python package.</li>
  <li>I have the freedom to restructure the database schema if a different layout would be more convenient for this type of query.</li>
  <li>Each set, if it exists is supposed to be unique.</li>
  <li>I am not interested in partial matches.</li>
  <li>The database scale is on the order of &lt; 1000 sets each of which contains &lt; 10 items each, so performance at this point is not a priority.</li>
  </ul>
  
  <p>Thanks in advance.</p>