Mysql Constraint problem

Posted by Bramjam on Stack Overflow See other posts from Stack Overflow or by Bramjam
Published on 2010-05-11T11:18:57Z Indexed on 2010/05/11 11:24 UTC
Read the original article Hit count: 113

Filed under:

this is my table
/* oefenreeks leerplan */
CREATE TABLE leerplan_oefenreeks
(
leerplan_oefenreeks_id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
leerplan_id INT NOT NULL,
oefenreeks_id INT NOT NULL,
plaats INT NOT NULL
);

/* fk */
ALTER TABLE leerplan_oefenreeks ADD CONSTRAINT fk_leerp_oefenr_leerplan FOREIGN KEY(leerplan_id) REFERENCES leerplan (leerplan_id) ON DELETE CASCADE;

ALTER TABLE leerplan_oefenreeks ADD CONSTRAINT fk_leerp_oefenr_oefenreeks FOREIGN KEY(oefenreeks_id) REFERENCES oefenreeks (oefenreeks_id) ON DELETE CASCADE;

/* unique s */

/*when I execute the nexline, my fk_leerp_oefenr_leerplan constraint vanishes/disappears*/

ALTER TABLE leerplan_oefenreeks ADD CONSTRAINT un_leerp_oefenr UNIQUE(leerplan_id, oefenreeks_id);

ALTER TABLE leerplan_oefenreeks ADD CONSTRAINT un_leerp_oefenr_plaats UNIQUE(leerplan_id, plaats);

when I go and check only 3 constraints exist (fk_leerp_oefenr_leerplan is gone) I don't understand why this happens, plz tell me (if you need more info just ask ;)

© Stack Overflow or respective owner

Related posts about mysql