title: Magento 1.7 cannot reindex product flat data
body: <h2>Magento 1.7 cannot reindex product flat data... I get the following error when trying to reindex my database.</h2>
  
  <pre><code>Product Flat Data index process unknown error:
  exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot          add or update a child row: a foreign key constraint fails (`d014505f`.&lt;result 2 when explaining filename '#sql-1f6c_39a11d'&gt;, CONSTRAINT `FK_CAT_PRD_FLAT_1_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`e)' in /www/htdocs/w00f5624/lib/Zend/Db/Statement/Pdo.php:228
  
  Stack trace:#0 /www/htdocs/w00f5624/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement-    &gt;execute(Array)
  #1 /www/htdocs/w00f5624/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo-&gt;_execute(Array)
  #2 /www/htdocs/w00f5624/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql-&gt;_execute(Array)
  #3 /www/htdocs/w00f5624/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement-&gt;execute(Array)
  #4 /www/htdocs/w00f5624/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract-&gt;query('ALTER TABLE `ca...', Array)
  #5 /www/htdocs/w00f5624/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract-&gt;query('ALTER TABLE `ca...', Array)
  #6 /www/htdocs/w00f5624/lib/Varien/Db/Adapter/Pdo/Mysql.php(340): Varien_Db_Adapter_Pdo_Mysql-&gt;query('ALTER TABLE `ca...')
  #7 /www/htdocs/w00f5624/lib/Varien/Db/Adapter/Pdo/Mysql.php(2569): Varien_Db_Adapter_Pdo_Mysql-&gt;raw_query('ALTER TABLE `ca...')
  #8 /www/htdocs/w00f5624/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(816): Varien_Db_Adapter_Pdo_Mysql-&gt;addForeignKey('FK_CAT_PRD_FLAT...', 'catalog_product...', 'entity_id', 'catalog_product...', 'entity_id', 'CASCADE', 'CASCADE')
  #9 /www/htdocs/w00f5624/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(1390): Mage_Catalog_Model_Resource_Product_Flat_Indexer-&gt;prepareFlatTable(1)
  #10 /www/htdocs/w00f5624/app/code/core/Mage/Catalog/Model/Product/Flat/Indexer.php(296): Mage_Catalog_Model_Resource_Product_Flat_Indexer-&gt;reindexAll()
  #11 /www/htdocs/w00f5624/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php(336): Mage_Catalog_Model_Product_Flat_Indexer-&gt;reindexAll()
  #12 /www/htdocs/w00f5624/app/code/core/Mage/Index/Model/Process.php(209): Mage_Catalog_Model_Product_Indexer_Flat-&gt;reindexAll()
  #13 /www/htdocs/w00f5624/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process-&gt;reindexAll()
  #14 /www/htdocs/w00f5624/shell/indexer.php(158): Mage_Index_Model_Process-&gt;reindexEverything()
  #15 /www/htdocs/w00f5624/shell/indexer.php(198): Mage_Shell_Compiler-&gt;run()
  #16 {main}
  </code></pre>
  
  <hr>