title: MySQL Keep Data until no child tables attached
body: <p>I'm a bit of a MySQL noob so please bear with me, I'm trying to find a way to keep something in <code>Parent Table</code> and require at least one child table have a foreign key tied with it. Hopefully an example makes sense.</p>
  
  <pre><code>                         Parent Table
                           ------------
                           theId int
                           someValue varchar(20)
                         /       |            \
                        /        |             \
                       /         |              \
  Open Table          /    Completed Table       \ Monitoring Table
  ------------------ /     ------------------      ------------------
  childTableId int         childTableId int        childTableId int
  someOtherData blob       someOtherData blob      someOtherData blob
  theId int (fk)           theId int (fk)          theId int(fk)
  </code></pre>
  
  <p>I have the 3 child data's all tracking different things and those records are only present for a certain amount of time, however the parent table is always the same throughout all stages. I need a way to make sure a child data can't be deleted if it's the only child table referencing the parent table (there can be 2 at times).</p>
  
  <p>Help?</p>