title: constraint that limits number of children in MySQL
body: <p>I have a databased which looks like </p>
  
  <pre><code>Root
      Child Table 1
          Child table referencing 1
      Child Table 2
      Child Table 3
      Child Table N
           Child Table referencing N
  </code></pre>
  
  <p>One of the requirements given to me is to limit the number of children for each row in root. </p>
  
  <p>There can only be 4 child1 rows per root row.</p>
  
  <p>There can only be 12 child2 rows per root row.</p>
  
  <p>etc.</p>
  
  <p>I know that I can build a set of checks into the business logic of my program but I was wondering if there is a way to include a set of constraints at the database that would do the sanity checks for me? <a href="http://dev.mysql.com/doc/refman/4.1/en/innodb-foreign-key-constraints.html" rel="nofollow">None of the foreign key reference options seem to do what I want</a>. </p>