Hi,
I was trying to import some of the data into the 'datavalue' table of my
database i was getting th following error

Error Code : 1452
Cannot add or update a child row: a foreign key constraint fails
(`gtest1/datavalue`, CONSTRAINT `FKEB92DC077A7A2FFA` FOREIGN KEY
(`dataElement`) REFERENCES `dataelement` (`id`))
(5428 ms taken)


My table structures:

dataelement  CREATE TABLE `dataelement`
(
              `id` int(11) NOT NULL
auto_increment,
              `name` varchar(255) NOT
NULL,
              `shortName` varchar(255) default
NULL,
              `description` varchar(255) default
NULL,
              `active` bit(1) default
NULL,
              `type` varchar(255) default
NULL,
              `aggregationOperator` int(11) default
NULL,
              `parent` int(11) default
NULL,
              `alternativeName` varchar(255) default
NULL,
              `code` varchar(255) default
NULL,
              PRIMARY KEY
(`id`),
              UNIQUE KEY `name`
(`name`),
              UNIQUE KEY `shortName`
(`shortName`),
              UNIQUE KEY `alternativeName`
(`alternativeName`),
              UNIQUE KEY `code`
(`code`),
              KEY `FKE1611C125DC41C92`
(`parent`),
              CONSTRAINT `FKE1611C125DC41C92` FOREIGN KEY (`parent`)
REFERENCES `dataelement` (`id`)
            ) ENGINE=InnoDB DEFAULT
CHARSET=utf8

----------

datavalue  CREATE TABLE `datavalue`
(
            `dataElement` int(11) NOT
NULL,
            `period` int(11) NOT
NULL,
            `source` varchar(255) NOT
NULL,
            `flag` varchar(255) default
NULL,
            `value` varchar(255) default
NULL,
            `storedBy` varchar(255) default
NULL,
            `timestamp` datetime default
NULL,
            `comment` varchar(255) default
NULL,
            PRIMARY KEY
(`dataElement`,`period`,`source`),

            KEY `FKEB92DC077F9CE9CC`
(`period`),
            KEY `FKEB92DC077A7A2FFA`
(`dataElement`),
            CONSTRAINT `FKEB92DC077A7A2FFA` FOREIGN KEY (`dataElement`)
REFERENCES `dataelement` (`id`),
            CONSTRAINT `FKEB92DC077F9CE9CC` FOREIGN KEY (`period`)
REFERENCES `period` (`id`)
          ) ENGINE=InnoDB DEFAULT
CHARSET=utf8

Reply via email to