1

I am trying to create a foreign key between ticket table of task_flow database with user table of sardia database:

  • user_id int(10) UNSIGNED No
  • Id int(10) UNSIGNED No

I created the query

ALTER TABLE ticket
ADD CONSTRAINT fk_u_id
FOREIGN KEY (user_id) REFERENCES sardia.user(Id);

"Foreign key constraint is incorrectly formed" Can somebody help how I can achieve this?

RandomUser
  • 117
  • 2
  • 15

1 Answers1

1

Someone has already ask something related to it, click here to see it.

Try something like this:

ALTER TABLE ticket ADD grade_id SMALLINT UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE ticket ADD CONSTRAINT fk_u_id FOREIGN KEY (user_id) REFERENCES sardia.user(Id);

Hope it helped you.