MySQL怎么给含有主键的字段添加信息

表的结构是这样的

img

    Insert into cure values
(330103,300366,'2017-11-10',null),
(330103,200601,'2017-11-25',null)


错误提示:> 1452 - Cannot add or update a child row: a foreign key constraint fails (`doctordb`.`cure`, CONSTRAINT `s` FOREIGN KEY (`SID`) REFERENCES `suffer` (`SID`))




主键外键的操作
ALTER TABLE cure ADD PRIMARY KEY (DID,SID);
alter table  cure add constraint  d  foreign key(DID) references doctorinfo(DID);
alter table cure add constraint s foreign key(SID) references suffer(SID);

患者编号是外键,也就是说患者表里有这个编号才可以添加,你可以先插入患者表,再插入治疗信息表