title: Can't Add Foreign Key in MySQL
body: <p>i have two tables naming 'customers' having 'productid' as primary key</p>
  
  <pre><code> CustomerID | CustomerName | ContactName | Address  | PostalCode | Country | ProductID
  ------------+--------------+-------------+----------+------------+---------+-----------
            1 | John         | Jones       | Payson   | 34213      | Germany |         2
            2 | Mary         | Edward      | Sandiego | 43561      | Mexico  |        34
            3 | Eric         | Howell      | Phoenix  | 50023      | Mexico  |        11
            4 | Gus          | Gray        | Tucson   | 50021      | USA     |        54
            5 | Erica        | Williams    | Payson   | 76983      | UK      |        67
            6 | Elroy        | Cleaver     | Baghdad  | 34721      | France  |        55
  </code></pre>
  
  <p>and 'products' having 'unit' as primary key</p>
  
  <pre><code> ProductID | ProductName   | SupplierID | CategoryID | Unit              |Price| Date
  -----------+---------------------------+------------+------------+----------------------+--
           1 | Chais         |          1 |          1 | 10 boxesx20 bags  | 18  | 2008-11-11
           2 | Chang         |          1 |          1 | 24-12 oz bottles  | 19  | 2008-11-09
           3 | Aniseed Syrup |          1 |          2 | 12-550 ml bottles | 10  | 2008-05-12
          15 | Genen Shouyu  |          6 |          2 | 24-250 ml bottles | 15  | 2008-06-23
          16 | Pavlova       |          7 |          3 | 32-500 g boxes    | 17  | 2007-12-30
          21 | Sir Rodney's  |          8 |          3 | 24 pkgs.x4 pieces | 10  | 2007-01-09
          25 | NuNuCa Nuß    |         11 |          3 | 20 - 450 g glasses| 14  | 2007-05-04
          36 | Inlagd Sill   |         17 |         18 | 24 - 250 g jars   | 19  | 2007-02-09
  </code></pre>
  
  <p>using the following code to make productid in products table as foreign key</p>
  
  <pre><code>alter table products add constraint ck foreign key(productid) references customers(productid);
  </code></pre>
  
  <p>but the above code ends stating </p>
  
  <blockquote>
    <p>ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (<code>products</code>.<code>#sql-6e0_2</code>, CONSTRAINT <code>ck</code> FOREIGN KEY (<code>ProductID</code>) REFEREN
    CES <code>customers</code> (<code>ProductID</code>))"</p>
  </blockquote>