title: MySQL Error 1064 when adding foreign key with MySQL Workbench
body: <p>So I have an error, when I want to add a foreign key. I added the foreign key in MySQL Workbench with an EER Diagram Model. The lines workbench tries to add are:`</p>
  
  <pre><code>CREATE SCHEMA IF NOT EXISTS `barberDB` DEFAULT CHARACTER SET latin1 ;
  USE `barberDB` ;
  
  -- -----------------------------------------------------
  -- Table `barberDB`.`BARBER`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `barberDB`.`BARBER` (
    `ID` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(45) NULL,
    PRIMARY KEY (`ID`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `barberDB`.`CUSTOMER`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `barberDB`.`CUSTOMER` (
    `ID` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(45) NULL,
    `isHaircut` INT NULL,
    `isBeard` INT NULL,
    `isEyebrows` INT NULL,
    `BARBER_ID` INT NOT NULL,
    PRIMARY KEY (`ID`),
    INDEX `fk_CUSTOMER_BARBER_idx` (`BARBER_ID` ASC) VISIBLE,
    CONSTRAINT `fk_CUSTOMER_BARBER`
      FOREIGN KEY (`BARBER_ID`)
      REFERENCES `barberDB`.`BARBER` (`ID`)
      ON DELETE CASCADE
      ON UPDATE CASCADE)
  ENGINE = InnoDB;
  
  
  SET SQL_MODE=@OLD_SQL_MODE;
  SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  </code></pre>
  
  <p>The error I get is:</p>
  
  <pre><code>ERROR: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VISIBLE,
    CONSTRAINT `fk_CUSTOMER_BARBER`
      FOREIGN KEY (`BARBER_ID`)
      REF' at line 12
  SQL Code:
          -- -----------------------------------------------------
          -- Table `barberDB`.`CUSTOMER`
          -- -----------------------------------------------------
          CREATE TABLE IF NOT EXISTS `barberDB`.`CUSTOMER` (
            `ID` INT NOT NULL AUTO_INCREMENT,
            `name` VARCHAR(45) NULL,
            `isHaircut` INT NULL,
            `isBeard` INT NULL,
            `isEyebrows` INT NULL,
            `BARBER_ID` INT NOT NULL,
            PRIMARY KEY (`ID`),
            INDEX `fk_CUSTOMER_BARBER_idx` (`BARBER_ID` ASC) VISIBLE,
            CONSTRAINT `fk_CUSTOMER_BARBER`
              FOREIGN KEY (`BARBER_ID`)
              REFERENCES `barberDB`.`BARBER` (`ID`)
              ON DELETE CASCADE
              ON UPDATE CASCADE)
          ENGINE = InnoDB
  
  SQL script execution finished: statements: 6 succeeded, 1 failed
  
  Fetching back view definitions in final form.
  Nothing to fetch
  </code></pre>
  
  <p>I searched for solutions and find that parenthesis are important or backticks, but since the code is created by the tool, it seems correct to me. 
  What could cause the error?</p>