Subject | Re: [firebird-support] Foreign key violation - but why??? |
---|---|
Author | Lucas Franzen |
Post date | 2005-03-08T10:55:10Z |
Bjoern,
Bjoern Reimer schrieb:
CREATE TABLE XPERT_ANMELDUNGEN (
ANMELDUNG_ID BIGINT NOT NULL,
PRUEFUNGSART_ID INTEGER NOT NULL,
PERSON_ID INTEGER NOT NULL,
XP_TERM_ID INTEGER NOT NULL,
ZAHLUNGSSTATUS SMALLINT DEFAULT 0 NOT NULL,
/* ADD THIS LINE */
CONSTRAINT PK_XPERT_ANMELDUNGEN PRIMARY KEY ( ANMELDUNG_ID )
);
Otherwise your ForeignKey definition should fail with an error like:
unsuccessful metadata update
could not find UNIQUE INDEX with specified columns
Luc.
Bjoern Reimer schrieb:
> Hi,You have to define a primary key on your table(s).
>
> (Firebird 1.5.1 CS on Linux)
>
> Here is my situation:
>
> Two tables with one record each. I want to create a foreign key
> constraint from one to the other.
>
>
> CREATE TABLE XPERT_ANMELDUNGEN (
> ANMELDUNG_ID BIGINT NOT NULL,
> PRUEFUNGSART_ID INTEGER NOT NULL,
> PERSON_ID INTEGER NOT NULL,
> XP_TERM_ID INTEGER NOT NULL,
> ZAHLUNGSSTATUS SMALLINT DEFAULT 0 NOT NULL
> );
CREATE TABLE XPERT_ANMELDUNGEN (
ANMELDUNG_ID BIGINT NOT NULL,
PRUEFUNGSART_ID INTEGER NOT NULL,
PERSON_ID INTEGER NOT NULL,
XP_TERM_ID INTEGER NOT NULL,
ZAHLUNGSSTATUS SMALLINT DEFAULT 0 NOT NULL,
/* ADD THIS LINE */
CONSTRAINT PK_XPERT_ANMELDUNGEN PRIMARY KEY ( ANMELDUNG_ID )
);
Otherwise your ForeignKey definition should fail with an error like:
unsuccessful metadata update
could not find UNIQUE INDEX with specified columns
Luc.