Home > OS >  Foreign key incorrectly formed MySQL workbench
Foreign key incorrectly formed MySQL workbench

Time:01-29

I am using MySQL workbench. I have made sure that the foreign key in my parent and child table are defined in the same terms: BIGINIT(20) UNIQUE, and yet I am still getting the 1005 error that says that the child table cannot be created because my foreign key constraint is incorrectly formed. I can't see what I am doing wrong this is a screenshot of my workbench.

Defining my child table and on the left, properties of the primary key column in parent table:
Defining my child table and on the left, properties of the primary key column in parent table

CodePudding user response:

try this out

CREATE TABLE `profiles_user`.`profiles` (
  `profile_id` BIGINT NOT NULL AUTO_INCREMENT,
  `user_id` BIGINT UNSIGNED NOT NULL,
  `profile_name` VARCHAR(30) NULL,
  `wiki_desc` VARCHAR(255) NULL,
  `twitter` VARCHAR(255) NULL,
  PRIMARY KEY (`profile_id`),
  UNIQUE INDEX `user_id_UNIQUE` (`user_id` ASC) VISIBLE,
  CONSTRAINT `fk_profiles`
    FOREIGN KEY (`user_id`)
    REFERENCES `profiles_user`.`users` (`user_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE);
  •  Tags:  
  • Related