title: Can not add foreign key constraint, How should i fix this error?
body: <p>I want to add foreign key constraint of the idDept in the Staff, But it tells me that "Error Code 1215(HY000)".</p>
  
  <p>The following is my SQL code, exported by workbench.</p>
  
  <p>I guess it may be caused by INDEX <code>idDept_idx</code> (<code>idDept</code> ASC)， but deleting it in my code is not work,too.</p>
  
  <pre><code>SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
  
  CREATE SCHEMA IF NOT EXISTS `Hospitalization` DEFAULT CHARACTER SET utf8 ;
  USE `Hospitalization` ;
  
  CREATE TABLE IF NOT EXISTS `Hospitalization`.`Dept` (
    `idDept` INT(2) ZEROFILL NOT NULL,
    `name` VARCHAR(45) NOT NULL,
    `director` INT(5) NOT NULL,
    `location` INT(3) NOT NULL,
    PRIMARY KEY (`idDept`))
  ENGINE = InnoDB;
  
  CREATE TABLE IF NOT EXISTS `Hospitalization`.`Staff` (
    `idStaff` INT(5) ZEROFILL NOT NULL,
    `name` VARCHAR(45) NOT NULL,
    `sex` CHAR(2) NOT NULL,
    `contact` VARCHAR(45) NOT NULL,
    `role` VARCHAR(45) NOT NULL,
    `password` VARCHAR(45) NOT NULL DEFAULT '123456',
    `idDept` INT(2) NOT NULL,
    PRIMARY KEY (`idStaff`),
    INDEX `idDept_idx` (`idDept` ASC),
    CONSTRAINT `idDept`
      FOREIGN KEY (`idDept`)
      REFERENCES `Hospitalization`.`Dept` (`idDept`)
      ON DELETE CASCADE
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  </code></pre>