title: ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails for existing tables
body: <p>I am getting following error while assigning foreign key to existing table column:</p>
  
  <blockquote>
    <p>ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (<code>c_x_parsing</code>.<code>#sql-787_1</code>, CONSTRAINT <code>#sql-787_1_ibfk_1</code> FOREIGN KEY (<code>nct_id</code>) REFERENCES <code>cdb</code> (<code>nct_id</code>))</p>
  </blockquote>
  
  <p>Below is the my query:</p>
  
  <pre><code>ALTER TABLE c_int ADD FOREIGN KEY (n_id) REFERENCES cdb (n_id);
  </code></pre>
  
  <p>While my parent table is cdb cdb and child table is c_int.</p>
  
  <p>Please suggest me the solution as I already tried with following commands: </p>
  
  <pre><code>ALTER TABLE cdb ENGINE=InnoDB;
  ALTER TABLE c_int ENGINE=InnoDB;
  </code></pre>