title: ERROR 1452 (23000): Cannot add or update a child row
body: <p>I have the following database and when I try to run the query that has been shown below I get the error that says <code>Cannot add or update a child row</code>. I do not understand why am I getting this error.</p>
  
  <p>The <code>object_id</code> that I am entering (327) exists in the database. I have tried this with other <code>object_id</code>s as well and the same error comes up. What is happening here?</p>
  
  <pre><code>    like_objects
  +-------------+---------+------+-----+---------+----------------+
  | Field       | Type    | Null | Key | Default | Extra          |
  +-------------+---------+------+-----+---------+----------------+
  | object_id   | int(11) | NO   | MUL | NULL    |                |
  | id          | int(11) | NO   | PRI | NULL    | auto_increment |
  | user_id     | int(11) | NO   | MUL | NULL    |                |
  +-------------+---------+------+-----+---------+----------------+
  
  objects
  +--------------+--------------+------+-----+---------+----------------+
  | Field        | Type         | Null | Key | Default | Extra          |
  +--------------+--------------+------+-----+---------+----------------+
  | object_name  | longtext     | NO   |     | NULL    |                |
  | object_desc  | longtext     | NO   |     | NULL    |                |
  | id           | int(11)      | NO   | PRI | NULL    | auto_increment |
  | likes        | int(11)      | NO   |     | NULL    |                |
  +--------------+--------------+------+-----+---------+----------------+
  </code></pre>
  
  <p>Here's the query and the error it produces:</p>
  
  <pre><code>insert into  like_objects (object_id,user_id) values (327,1)
  
  ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails 
  (`test_db`.`like_objects`, CONSTRAINT `object_id_refs_id_57f96810` FOREIGN KEY (`object_id`) 
  REFERENCES `objects` (`id`))
  </code></pre>
  
  <p>This is very strange because I have used a similar <code>like</code> logic for another table and it is working absolutely fine. </p>
  
  <p><strong>Important</strong> I have obtained <code>objects</code> table from a <code>mysqldump</code>. Initially the <code>objects</code> table was created form PhpMyAdmin and the like_objects table has been created by the <code>django models</code></p>