0

Im trying to set up a foreign key within one of my tables although I don't get the option to select foreign key constraints as shown in the below screenshot. Any idea on how I can go about setting foreign keys?

enter image description here

har07
  • 88,338
  • 12
  • 84
  • 137

2 Answers2

0

make sure you have both column type the same. without that, it will not show on your dropdown / unable to save

rezashamdani
  • 577
  • 6
  • 11
  • Yes they are both the same type, i have tried to put this into the SQL although continues to give syntax errors: FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE – Peter Connolly Mar 29 '15 at 09:41
0

simply go to sql and go with the following query

ALTER TABLE `table_name_with_foreignKey`
  ADD CONSTRAINT `foreignKey_constraint_name` 
  FOREIGN KEY (`Column_name_of_foreignkey`) 
  REFERENCES `table_having_referenceTokey`(`column_name_of_primaryKey`) 
  ON DELETE CASCADE 
  ON UPDATE CASCADE;
N.R
  • 191
  • 1
  • 13