cannot add foreign key constraint workbench

12 Views Asked by At

Executing the following SQL script in the server:

ERROR: Error 1215: Cannot add foreign key constraint
SQL Code:
        CREATE TABLE IF NOT EXISTS `telecom`.`jobreq` (
          `id` INT NOT NULL,
          `jobName` VARCHAR(45) NULL,
          `priority` VARCHAR(45) NULL,
          `dates` DATE NULL,
          `status` VARCHAR(45) NULL,
          `user` VARCHAR(45) NULL,
          `timestamp` DATE NULL,
          `service_id` INT(11) NOT NULL,
          `client_id` INT(11) NOT NULL,
          PRIMARY KEY (`id`, `service_id`, `client_id`),
          INDEX `fk_jobreq_service1_idx` (`service_id` ASC),
          INDEX `fk_jobreq_client1_idx` (`client_id` ASC),
          CONSTRAINT `fk_jobreq_service1`
            FOREIGN KEY (`service_id`)
            REFERENCES `telecom`.`service` (`id`)
            ON DELETE NO ACTION
            ON UPDATE NO ACTION,
          CONSTRAINT `fk_jobreq_client1`
            FOREIGN KEY (`client_id`)
            REFERENCES `telecom`.`client` (`id`)
            ON DELETE NO ACTION
            ON UPDATE NO ACTION)
        ENGINE = InnoDB

SQL script execution finished: statements: 12 succeeded, 1 failed

Fetching back view definitions in final form.
Nothing to fetch

I am unable to find out why I am getting this error can someone with a high intelligence please assist me.

1

There are 1 best solutions below

0
On BEST ANSWER

So it seems all I had to do was to change the name of the table and it went through im guessing somehow the name was magically somehow still in the system