title: Error 1061 (MYSQL Workbench) duplicate keys when creating indexes
body: <p>I cannot understand why I keep getting an 1061 error for key duplicates on indexes when I dont have any duplicates. I've looked at other stackoverflow posts regarding similar questions, and most had this issue when they had the same name for multiple foreign keys. However, that doesn't apply in my case.</p>
  
  <p>In a general nutshell what I've done is create a table linking books to tasks.
  Each book id will have a few tasks associated with that particular book. 
  It is a many many relationship i.e. many books will be associated with a specific task. And a specific task will be associated with many books. </p>
  
  <p><a href="https://i.stack.imgur.com/z3sNX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z3sNX.jpg" alt="enter image description here"></a></p>
  
  <p>So in between this many to many relationship I have a Books x Tasks table which acts as the intermediary. This table has its own primary key and two foreign keys. One is the book ID from the books table and the tasks id from the tasks table. Therefore they are both foreign keys. In that way I can link multiple tasks with multiple books each defined by it's own unique id within the booksxtasks table. </p>
  
  <p>When I forward engineer this, there is an error. </p>
  
  <blockquote>
    <p>Executing SQL script in server
    ERROR: Error 1061: Duplicate key name 'FK Tasks_TaskID_idx'
    SQL Code: CREATE INDEX `FK Tasks_TaskID_idx` ON `mydb`.`BooksxTasks` (`Tasks_TaskID` ASC)</p>
  </blockquote>
  
  <pre><code>  CREATE TABLE IF NOT EXISTS `mydb`.`BooksxTasks` (
    `BooksxTasksID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `Books_BookID` INT UNSIGNED NOT NULL,
    `Tasks_TaskID` TINYINT(2) UNSIGNED NOT NULL,
    PRIMARY KEY (`BooksxTasksID`),
    CONSTRAINT `FK Tasks_TaskID`
      FOREIGN KEY (`Tasks_TaskID`)
      REFERENCES `mydb`.`Tasks` (`TaskID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `FK Books_BooksID`
      FOREIGN KEY (`Books_BookID`)
      REFERENCES `mydb`.`Books` (`BookID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  CREATE INDEX `FK Tasks_TaskID_idx` ON `mydb`.`BooksxTasks` (`Tasks_TaskID` ASC);
  
  CREATE INDEX `FK Books_BooksID_idx` ON `mydb`.`BooksxTasks` (`Books_BookID` ASC);
  </code></pre>
  
  <p>I also checked to see all the names given to all the constraints in the entire database. There was no duplicate names. So where is this duplicate key error coming from?</p>