title: Error 1022 - Can't write; duplicate key in table
body: <p>I'm getting a 1022 error regarding duplicate keys on create table command. Having looked at the query, I can't understand where the duplication is taking place. Can anyone else see it? </p>
  
  <pre><code>SQL query:
  
  -- -----------------------------------------------------
  -- Table `apptwo`.`usercircle`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS  `apptwo`.`usercircle` (
  
   `idUserCircle` MEDIUMINT NOT NULL ,
   `userId` MEDIUMINT NULL ,
   `circleId` MEDIUMINT NULL ,
   `authUser` BINARY NULL ,
   `authOwner` BINARY NULL ,
   `startDate` DATETIME NULL ,
   `endDate` DATETIME NULL ,
  PRIMARY KEY (  `idUserCircle` ) ,
  INDEX  `iduser_idx` (  `userId` ASC ) ,
  INDEX  `idcategory_idx` (  `circleId` ASC ) ,
  CONSTRAINT  `iduser` FOREIGN KEY (  `userId` ) REFERENCES  `apptwo`.`user` (
  `idUser`
  ) ON DELETE NO ACTION ON UPDATE NO ACTION ,
  CONSTRAINT  `idcategory` FOREIGN KEY (  `circleId` ) REFERENCES  `apptwo`.`circle` (
  `idCircle`
  ) ON DELETE NO ACTION ON UPDATE NO ACTION
  ) ENGINE = INNODB;
  
  MySQL said: Documentation
  
  #1022 - Can't write; duplicate key in table 'usercircle' 
  </code></pre>