MySQL Cannot Add Foreign Key Constraint

To find the specific error run this: And look in the LATEST FOREIGN KEY ERROR section. The data type for the child column must match the parent column exactly. For example, since medicalhistory.MedicalHistoryID is an INT, Patient.MedicalHistory also needs to be an INT, not a SMALLINT. Also, you should run the query set foreign_key_checks=0 before running the DDL so you can create the tables in an … Read more