title: Modeling this in a SQLite relational database
body: <p>Suppose I have a <code>Citizen</code> table (columns: <code>rowid</code>, <code>name</code>) and a <code>Race</code> table (columns: <code>rowid</code>, <code>name</code>). These are citizens of the world and the races are "Caucasian", "African American", etc. The <code>rowid</code>s are the default columns provided by SQLite.</p>
  
  <p>There are billions of citizens. There are very few races, say 50.</p>
  
  <p>What is the SQLite way of connecting each citizen to his or her race?</p>
  
  <p>In a standard programming language, I would simply attach to each race a set containing all the corresponding citizen <code>rowid</code>s. This would allow me to do various things:</p>
  
  <ul>
  <li>Given a race, quickly find all its members.</li>
  <li>Given a citizen, quickly loop through the races (since there are few races) and look into the set and find his or her race.</li>
  <li>Adding a citizen is simple. I just put the new <code>rowid</code> into his or her race's set.</li>
  <li>Similarly, deleting a citizen is simple.</li>
  </ul>
  
  <p><strong>How can I do this in SQLite?</strong> Could this be tricky given that SQLite only has B-tree indexes? Maybe this kind of data doesn't belong in a SQLite database to begin with?</p>