title: mysql error 1215 cannot add foreign key contraint
body: <pre><code>DROP TABLE IF EXISTS desk;
  DROP TABLE IF EXISTS user;
  DROP TABLE IF EXISTS authority;
  
  CREATE TABLE authority
  (
      authorityId     INT             NOT NULL AUTO_INCREMENT PRIMARY KEY,
      deskId          INT             DEFAULT 0,              
      authorityName   VARCHAR(50)     NOT NULL,
      descriptions    VARCHAR(100)    NOT NULL,
      userLevel       TINYINT         NOT NULL,
      actions         VARCHAR(300)    DEFAULT NULL,
      setDate         TIMESTAMP       DEFAULT CURRENT_TIMESTAMP
  );
  
  CREATE TABLE desk
  (
      deskId          INT             NOT NULL AUTO_INCREMENT PRIMARY KEY,
      deskName        CHAR(50)        NOT NULL,
      deskLink        VARCHAR(100)    NOT NULL,
      details         VARCHAR(350)    DEFAULT NULL,
      setDate         TIMESTAMP       NOT NULL DEFAULT CURRENT_TIMESTAMP,
      closeDate       TIMESTAMP       DEFAULT NULL,
      userId          INT             DEFAULT NULL,                   
      status          TINYINT(1)          DEFAULT 0
  );
  
  CREATE TABLE user 
  (
      userId      INT                 NOT NULL AUTO_INCREMENT PRIMARY KEY,
      userName    CHAR(150)           NOT NULL,
      password    VARCHAR(500)        NOT NULL,
      department  VARCHAR(150)        DEFAULT NULL,
      deskId      INT                 NOT NULL,
      status      TINYINT(1)          DEFAULT NULL,
      userLevel   TINYINT             NOT NULL,
      FOREIGN KEY (deskId) REFERENCES desk (deskId) ON DELETE CASCADE,
      FOREIGN KEY (userLevel) REFERENCES authority (userLevel)
  );
  </code></pre>
  
  <p><strong>Error while executing query.</strong> 
  Error Code: 1215 .Cannot add foreign key contraint</p>
  
  <p>I have tried many way but still cannot solve the problem, i tried change userLevel type to INT both table user and authority but nothing went to better </p>
  
  <p>I really not know how to fix this problem, please help </p>