title: Cannot add or update a child row: foreign key with mysql
body: <p>I created two tables students and orders, I tried to add a foreign key to the table "orders" but i have this error :</p>
  
  <pre><code>Cannot add or update a child row: a foreign key constraint fails
  </code></pre>
  
  <p>table STUDENTS:</p>
  
  <pre><code> CREATE TABLE STUDENTS (  
   ID varchar(50)  NOT NULL,  
   NAME VARCHAR (20) NOT NULL,  
   AGE INT NOT NULL,  
   ADDRESS CHAR (25),  
   PRIMARY KEY (ID)  
    ) 
  </code></pre>
  
  <p>Table ORDERS</p>
  
  <pre><code>CREATE TABLE Orders  
  (O_Id int NOT NULL PRIMAY KEY,  
  Order_No int NOT NULL,ID varchar(50))  
  </code></pre>
  
  <p>Add foreign key to "orders":</p>
  
  <pre><code>ALTER TABLE Orders  
  ADD CONSTRAINT fk_PerOrders  
  FOREIGN KEY(ID)  
  REFERENCES STUDENTS (ID) 
  </code></pre>