I don't get it. Can someone explain my failure here:
CREATE TABLE IF NOT EXISTS `mytable`.`Employee_Service` (
`Employee_Service_Id` INT NOT NULL,
`Created_At` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
`Updated_At` TIMESTAMP NULL,
PRIMARY KEY (`Employee_Service_Id`),
CONSTRAINT `Employee`
FOREIGN KEY (`Employee_Service_Id`)
REFERENCES `mytable`.`Employees` (`Employee_Id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `Service`
FOREIGN KEY (`Employee_Service_Id`)
REFERENCES `mytable`.`Services` (`Service_Id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
The log-file says:
Error 1022: Can't write; duplicate key in table 'employee_service'
To understand what I want to do with that: The table "Employee_Service" is the connection between the tables "Employees" and "Services". In that table I want to store the "Employee_Id" from the table "Employees" and connect it with the "Service_Id" from the table "Services". So I can get the relation that an employee has a service. But what is wrong with my table, especially with the foreing keys???