title: How to add foreign key to MySQL table?
body: <p>I use <code>MySQL</code> with <code>InnoDB</code> engine. I double-checked type of columns. But always have:</p>
  
  <p><code>Error Code: 1215. Cannot add foreign key constraint</code></p>
  
  <p>I tried:</p>
  
  <pre><code>ALTER TABLE `mail`.`boxes`  
      ADD CONSTRAINT FK_id 
      FOREIGN KEY (id) 
      REFERENCES `mail`.`users` (id)
      ON UPDATE NO ACTION 
      ON DELETE NO ACTION; 
  </code></pre>
  
  <p>and</p>
  
  <pre><code>ALTER TABLE `mail`.`boxes` 
    ADD FOREIGN KEY (id)
    REFERENCES `mail`.`users` (id)
  </code></pre>
  
  <p>Nothing works(((</p>
  
  <p>Please, help, what I am doing wrong (except choosing MySQL :-) )?</p>