Subject | Re: [firebird-support] adding foreign key referencing multi-column primary key |
---|---|
Author | Magnus Titho |
Post date | 2005-03-15T15:44:14Z |
melanie grieb schrieb am 15.03.2005 16:07:
a combined primary key (ALIGNMENT_NR, AL_POSITION_NR) because in this
example one integer field would have to hold the values of two integer
fields.
The table SEQ_POSITION must either have two columns for the FK or
AL_POSITION must have one unique field (e.g. "ID", filled by a generator).
(AL_POSITION_NR, ALIGNMENT_NR) can still have an unique constraint:
alter table AL_POSITION add constraint CID_AL_POSITION unique
(AL_POSITION_NR, ALIGNMENT_NR)
Magnus
>I don't think a single field (AL_POSITION_ID) can have an foreign key to
> I am trying to reference a multi-column primary key using a foreign key...
>
> ALTER TABLE "SEQ_POSITION" ADD CONSTRAINT "FK_AL_POSITION_ID" FOREIGN
> KEY("AL_POSITION_ID")
> REFERENCES AL_POSITION("ALIGNMENT_NR", "AL_POSITION_NR")
> ON UPDATE CASCADE
> ON DELETE CASCADE
a combined primary key (ALIGNMENT_NR, AL_POSITION_NR) because in this
example one integer field would have to hold the values of two integer
fields.
The table SEQ_POSITION must either have two columns for the FK or
AL_POSITION must have one unique field (e.g. "ID", filled by a generator).
(AL_POSITION_NR, ALIGNMENT_NR) can still have an unique constraint:
alter table AL_POSITION add constraint CID_AL_POSITION unique
(AL_POSITION_NR, ALIGNMENT_NR)
Magnus