title: Error Code: 1215 Cannot add foreign key constraint
body: <p>I'm trying to create a health management DB, I get this error. What is the problem?</p>
  
  <pre><code>-- table glocation
  
  CREATE TABLE `MOH`.`glocation` (
  `street` VARCHAR(20) NOT NULL,
  `city` VARCHAR(20) NOT NULL,
  `state` VARCHAR(20) NOT NULL,
  `geolocation` INT(8),
  PRIMARY KEY (`street`, `city`, `state`));
  
  -- table patient
  
  CREATE TABLE `MOH`.`patient` (
  `PID` INT(6) zerofill UNSIGNED NOT NULL AUTO_INCREMENT,
  `first_name` VARCHAR(45) NOT NULL,
  `last_name` VARCHAR(45) NOT NULL,
  `sex` VARCHAR(10),
  `b_insurance` VARCHAR(45),
  `s_insurance` VARCHAR(45),
  `education` VARCHAR(20),
  `job` VARCHAR(20),
  `street` VARCHAR(20),
  `city` VARCHAR(20),
  `state` VARCHAR(20),
  `date_of_birth` date,
  `license` boolean,
  PRIMARY KEY (`PID`),
  CONSTRAINT `street`
    FOREIGN KEY (`street`)
    REFERENCES `MOH`.`glocation` (`street`),
  CONSTRAINT `city`
    FOREIGN KEY (`city`)
    REFERENCES `MOH`.`glocation` (`city`),
  CONSTRAINT `state`
    FOREIGN KEY (`state`)
    REFERENCES `MOH`.`glocation` (`state`));
  </code></pre>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>CREATE TABLE <code>MOH</code>.<code>patient</code> (...)    Error Code: 1215. Cannot add
    foreign key constraint</p>
  </blockquote>