Subject Re: [ib-support] Fw: Problem creating foreign key
Author Luiz
> >I have two tables that have a one-to-many relationship. in the child
table I am trying to create a foreign key referencing the parent. When I
execute the DDL the it gives me the following error...
> >
> >"This operation is not defined for system tables.
> > unsuccessful metadata update.
> > STORE RDB$REF_CONSTRAINTS failed.
> > action cancelled by trigger (1) to preserve data integrity.
> > Name of Referential Constraint not defined in constraints table."
> >
> >Obviously there is something that wrong, but I'm not exactly sure :-(
> >
> >Below are the table definitions...
> >
> >CREATE TABLE SKYSTATUS
> >(
> > STATUSCODE VARCHAR(5) NOT NULL,
> > DESCRIPTION VARCHAR(100) NOT NULL,
> >
> > PRIMARY KEY (STATUSCODE)
> >);
> >
> >Create Unique Index xSkyStatusDescription on SkyStatus(Description)
> >
> >CREATE TABLE SKYCLIENTDIARY
> >(
> > ACCNO VARCHAR(20) NOT NULL,
> > DATEOFENTRY TIMESTAMP NOT NULL,
> > TIMEOFENTRY VARCHAR(20) NOT NULL,
> > CUSER VARCHAR(30),
> > CDATE TIMESTAMP,
> > CTIME VARCHAR(20),
> > ENTRYTYPE VARCHAR(100) NOT NULL,
> >
> > PRIMARY KEY (ACCNO, DATEOFENTRY, TIMEOFENTRY),
> > FOREIGN KEY (EntryType) REFERENCES SkyStatus (Description)
> > ON UPDATE CASCADE
> > ON DELETE CASCADE
> >);
> >
> >If anyone has any ideas I would appreciate it.
>
> This seems to be a "catch-all" error for all foreign key errors. In this
case you are getting it because the foreign key column is being referenced
to a column which isn't the primary key.


Helen,

I am in doubt now.

He have a Unique Index as:

Create Unique Index xSkyStatusDescription on SkyStatus(Description)

Does the FKs don't can be create referencing a Unique Index?

Luiz.