Subject RE: [firebird-support] Re: Copy records
Author Helen Borrie
At 04:32 PM 5/08/2004 +0200, you wrote:
> > >>Violation of PRIMARY or UNIQUE KEY constraints "INTEG_94" on table
> > >>"MATCONTI"
> > >
> > > Maybe I should tell before, that both MC_MAT_KEY and MC_MAT_KC
> > are primary keys.
>Thanks Lester for your answer.
> > If just the combination should be unique then the PRIMARY KEY should
> > contain both, but if MC_MAT_KEY is a generator, the it will always be
> > unique, so just drop MC_MAT_KC from the primary key.
>The combination of both should be unique. There is no generator in this
>I don't know, if I understand it now:
>I tought, that if the table has two primary keys, there should be a unique

A table can never have two primary keys. Only one. Any unique column can
be the primary key; or a combination of columns where every instance of
the combination is unique.

You can also have a UNIQUE CONSTRAINT on a column or combination of columns
that is not the primary key. Sometimes people refer to such a constraint
as an "alternative key" but it is still not the primary key. You can
reference either the primary key column(s) or the key column(s) of a UNIQUE
constraint from a foreign key.

If you have a generated value (your "autoincrement key") for your primary
key, you don't need (and should not have) any other columns as part of the
primary key.