title: How to test tables linked with foreign keys?
body: <p>I am working with mysql and codeigniter using the redbean ORM. After implementing a foreign key for many to many assosciation I got the following error when I run:</p>
  
  <pre><code>drop TABLE IF EXISTS `temp`
  
  Integrity constraint violation: 1217 Cannot delete or update a parent row: a foreign key constraint fails thrown
  </code></pre>
  
  <p>I then entered SHOW ENGINE INNODB STATUS into phpmyadmin. The output includes:</p>
  
  <pre><code>LATEST FOREIGN KEY ERROR------------------------:  Cannot drop table `db1`.`temp`because it is referenced by `db1`.`temp_workers`.
  </code></pre>
  
  <p>In other words another table references the FK. For testing purposes I think the best thing to do is to drop all the associated tables and recreate them using the controller I'm testing. Is this the best way to go? I've tried:</p>
  
  <pre><code>drop TABLE IF EXISTS `temp` `temp_workers`
  </code></pre>
  
  <p>, but I'm still getting the above error, and the drop command does not work. Also:</p>
  
  <pre><code>truncate TABLE `temp`, `temp_workers`
  </code></pre>
  
  <p>gives:</p>
  
  <pre><code>You have an error in your SQL syntax
  </code></pre>