My problem is as follows, I have 2 COORDINATION and NACCLE_ACADEMIC tables, the relationship between them is N: M (many to many), the structure of the table COORDINATION and NACCLEO_ACADÉMICO the table is as follows:
CREATE TABLE coordinacion ( idcoord int(11) NOT NULL, nomcoord varchar(50) NOT NULL, ubicacion varchar(20) NOT NULL, CONSTRAINT pk_coordinacion primary key(idcoord) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE nucleo_academico ( idnucleo int(11) NOT NULL, nomnucleo varchar(150) NOT NULL, CONSTRAINT pk_nucleo_academico primary key(idnucleo) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
So far so good, the tables are created normally, Now when I proceed to create the table of the relationship OCUPA to store the respective fields, I throw this error "# 1215 - No can add foreign key constraint ", Here is the structure of the table OCUPA:
CREATE TABLE ocupa( idcoord int(11) NOT NULL, idnucleo int(11) NOT NULL, foreign key(idcoord) REFERENCES coordinacion(idcoord), foreign key(idnucleo) REFERENCES coordinacion(idnucleo), primary key(idcoord,idnucleo) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
I would be very grateful if you would give me a hand with this problem, I have already changed several things and corrected several errors, I just need to correct this to continue advancing with my project ...