Hola, tengo un problema en un insert que no se solucionar. Tengo 2 innodb tablas:
CREATE TABLE IF NOT EXISTS `comp-name` (
`CompId` int(11) NOT NULL auto_increment,
`CompName` varchar(255) default NULL,
PRIMARY KEY (`CompId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `comp-dep-access` (
`CompId` int(11) NOT NULL default '0',
`DepId` int(11) NOT NULL default '0',
PRIMARY KEY (`CompId`,`DepId`),
KEY `depid` (`DepId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `comp-name`
ADD CONSTRAINT `compid_key` FOREIGN KEY (`CompId`) REFERENCES `comp-dep-access` (`CompId`);
ALTER TABLE `comp-dep-access`
ADD CONSTRAINT `depid` FOREIGN KEY (`DepId`) REFERENCES `comp-department` (`DepId`);
Cuando intento insertar en comp-name
1452 - Cannot add or update a child row: a foreign key constraint fails (`operationware/comp-name`, CONSTRAINT `compid_key` FOREIGN KEY (`CompId`) REFERENCES `comp-dep-access` (`CompId`))
No tengo mucha experiencia con innodb, alguien me podría decir cual es el error?
Gracias