title: How to refactor database schema with dual-purpose foreign key
body: <p>I have two general types of "users", <code>Person</code> and <code>Page</code>. They can preform the same actions (voting, commenting, posting, etc.), but they have intrinsically different information. In a nutshell, a <code>Person</code> has a <code>first_name</code>, <code>last_name</code>, <code>gender</code>, and <code>birthday</code>. A <code>Page</code> has a <code>title</code>, <code>description</code>, and <code>basic_info</code>.</p>
  
  <p>Both Person and Page can perform the <em>same</em> actions throughout the system, so when designing the database schema, I feel that it is necessary relate everything back to a central <code>id</code> column. Otherwise, I think the complexity of the system would increase drastically (although maybe I am incorrect in saying this.)</p>
  
  <p>Given this, I would like to have a "mapping" table. For example, let's call this table <code>Map</code>. <code>Map</code> has an <code>id</code> (the central id which everything is identified by), <code>destination_id</code> (the id of either the person or the page, depending on the next column...) and <code>type</code> (either Person or Page).</p>
  
  <p>If, for example, <code>type</code> is "Person", I know to look in the User table, and if <code>type</code> is "Page", I know to look in the Page table to get the necessary info.</p>
  
  <p>I am not happy with this design because it introduces a "dual-purpose foreign key." -- I have a "Foreign Key" in the <code>Map</code> table which can refer to any number of other tables.</p>
  
  <p>How do I refactor this so that I can:</p>
  
  <ol>
  <li>Preferably, allow for additional user_types to be added (Person, Page, and then Group, for instance)</li>
  <li>Get rid of that dual-purpose foreign key</li>
  </ol>
  
  <p>A possible alternative: Have two columns in the <code>Map</code> table, <code>page_id</code> and <code>person_id</code>, both of which are actual Foreign Keys, but only one of which is not null. Whichever one is not null is obviously a true Foreign Key to the proper user_type's info (Page or Person).</p>
  
  <p>This seems moderately reasonable, but it doesn't necessarily satisfy my 1st condition as 'cleanly' as I would like, and it seems rather clunky.</p>
  
  <p>How can I refactor this?</p>