Hi Guys
I have two tables, one called ‘meetme’ and the other called ‘frontpage_conferences’.
I have a dual primary key on the meetme table which consists of ‘confno’ and ‘starttime’.
I have a foreign key inside frontpage_conferences which links to the primary key in meetme.
Whenever I try to add to the frontpage_conferences table I get this error:
Cannot add or update a child row: a foreign key constraint fails (03talk
.frontpage_conferences
, CONSTRAINT fk_frontpage_conferences_meetme1
FOREIGN KEY (meetme_confno
, meetme_starttime
) REFERENCES meetme
(confno
, starttime
) ON DELETE NO ACTIO)
It’s driving me mad.
Here is my table structure sql:
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE TABLE IF NOT EXISTS `meetme` (
`confno` CHAR(80) NOT NULL DEFAULT '0' ,
`starttime` DATETIME NOT NULL DEFAULT '2001-01-01 00:00:00' ,
`endtime` DATETIME NOT NULL DEFAULT '2099-12-31 23:59:59' ,
`pin` CHAR(20) NULL DEFAULT NULL ,
`opts` CHAR(100) NULL DEFAULT NULL ,
`adminpin` CHAR(20) NULL DEFAULT NULL ,
`adminopts` CHAR(100) NULL DEFAULT NULL ,
`members` INT(11) NOT NULL DEFAULT '0' ,
`maxusers` INT(11) NOT NULL DEFAULT '0' ,
PRIMARY KEY (`confno`, `starttime`) );
-- -----------------------------------------------------
-- Table `03talk`.`frontpage_conferences`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `frontpage_conferences` ;
CREATE TABLE IF NOT EXISTS `03talk`.`frontpage_conferences` (
`id` INT NOT NULL ,
`meetme_confno` CHAR(80) NOT NULL ,
`meetme_starttime` DATETIME NOT NULL ,
`frontpage_user_id` INT NOT NULL ,
`date` DATETIME NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_frontpage_conferences_meetme1` (`meetme_confno` ASC, `meetme_starttime` ASC) ,
INDEX `fk_frontpage_conferences_frontpage_users1` (`frontpage_user_id` ASC) ,
CONSTRAINT `fk_frontpage_conferences_meetme1`
FOREIGN KEY (`meetme_confno` , `meetme_starttime` )
REFERENCES `03talk`.`meetme` (`confno` , `starttime` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_frontpage_conferences_frontpage_users1`
FOREIGN KEY (`frontpage_user_id` )
REFERENCES `03talk`.`frontpage_users` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
Anybody able to help me with this?