Subject | Help with Add Constraint Foreign Key on cascade delete |
---|---|
Author | Hardee Mahoney |
Post date | 2009-05-15T14:25:20Z |
Hello,
I am trying to set up an Foreign Key with a cascade delete but am getting an
error message
My tables are:
CREATE TABLE InflationDataSets (
InflationDataSetID SMALLINT PRIMARY KEY,
SetupID SMALLINT NOT NULL,
InflationDataSetName VARCHAR(255) NOT NULL
)
CREATE TABLE InflationEntries (
InflationDataSetID SMALLINT NOT NULL,
YYear SMALLINT NOT NULL,
AllGoodsIndex FLOAT NOT NULL,
MedicalCostIndex FLOAT NOT NULL,
WageIndex FLOAT NOT NULL
)
ALTER TABLE InflationEntries
ADD CONSTRAINT PK_InflationEntries
PRIMARY KEY(InflationDatasetID, YYear);
My Alter table statement is
ALTER TABLE InflationEntries
ADD CONSTRAINT FK_InflationEntries
FOREIGN KEY (InflationDataSetID) REFERENCES InflationDataSets
(InflationDataSetID)
ON DELETE CASCADE
The error message (in FlameRobin) is
SQL Message: -530
violation of FOREIGN KEY constraint ""
Engine Code: 335544466
violation of FOREIGN KEY constraint "INTEG_2189" on table INFLATIONDATASETS
Foreign key reference target does not exist
The INTEG_2189 constraint is the primary key on InflationDatasets.
I hope someone can indicate to me where I am going wrong. I have a lot of
tables I would like to develope similar delete cascades for.
Thanks in advance,
Hardee Mahoney
Washington, DC
[Non-text portions of this message have been removed]
I am trying to set up an Foreign Key with a cascade delete but am getting an
error message
My tables are:
CREATE TABLE InflationDataSets (
InflationDataSetID SMALLINT PRIMARY KEY,
SetupID SMALLINT NOT NULL,
InflationDataSetName VARCHAR(255) NOT NULL
)
CREATE TABLE InflationEntries (
InflationDataSetID SMALLINT NOT NULL,
YYear SMALLINT NOT NULL,
AllGoodsIndex FLOAT NOT NULL,
MedicalCostIndex FLOAT NOT NULL,
WageIndex FLOAT NOT NULL
)
ALTER TABLE InflationEntries
ADD CONSTRAINT PK_InflationEntries
PRIMARY KEY(InflationDatasetID, YYear);
My Alter table statement is
ALTER TABLE InflationEntries
ADD CONSTRAINT FK_InflationEntries
FOREIGN KEY (InflationDataSetID) REFERENCES InflationDataSets
(InflationDataSetID)
ON DELETE CASCADE
The error message (in FlameRobin) is
SQL Message: -530
violation of FOREIGN KEY constraint ""
Engine Code: 335544466
violation of FOREIGN KEY constraint "INTEG_2189" on table INFLATIONDATASETS
Foreign key reference target does not exist
The INTEG_2189 constraint is the primary key on InflationDatasets.
I hope someone can indicate to me where I am going wrong. I have a lot of
tables I would like to develope similar delete cascades for.
Thanks in advance,
Hardee Mahoney
Washington, DC
[Non-text portions of this message have been removed]