title: Best MySQL Table Structure: 2 Parents, 1 Child
body: <p>I have two parent tables, BusinessGroup and SocialGroup, and one child table, Members.  A Member can belong to either parent, but not both.</p>
  
  <p>As far as I can see, there are two options for constructing the child table.</p>
  
  <p>Opt 1: Include a field for ParentType, and another for ParentID.  The ParentType would be an enum (Business, Social) and the ParentID would be the PK from the respective parent table.</p>
  
  <p>Opt 2: Include a field for BusinessGroupID, and another for SocialGroupID.  In this case, the fields would need to be nullable, and only one could contain a value.</p>
  
  <p>Any ideas on which approach is best?</p>
  
  <p>I tried option 1 in MySQL, and created two foreign keys from the child back to the parents.  I ran into trouble when inserting values though, since MySQL was expecting a corresponding value in BOTH parent tables.</p>
  
  <p>As a supplementary question: how do things change if I have a larger number of parents, e.g. 6?</p>
  
  <p>Thanks!</p>