Subject Re: [firebird-support] A unique index which is not?
Author Avi Schwartz
Helen Borrie wrote:

>At 04:05 PM 17/09/2004 -0500, you wrote:
>
>
>>I have this strange problem. I have two tables which I am trying to
>>create a foreign key relationship between them. However, even though I
>>create the unique index before attempting to create the FK relationship
>>it fails claiming that the unique index cannot be found. Any idea what
>>may the problem be? This is 1.5.1 on Linux.
>>
>>
>
>Yes. You can't form a FK to a unique INDEX. It has to be a UNIQUE
>constraint. A unique index isn't a UNIQUE constraint.
>
>What you really needed here was not this:
>
> CREATE UNIQUE INDEX unique_val ON repl_type (repl_type_code);
>
>but this:
>ALTER TABLE repl_type
> ADD CONSTRAINT uq_repl_type_code
> UNIQUE (repl_type_code);
>
>Make sure you drop the unique index before you create the UNIQUE constraint.
>
>And, yes, the exception message IS misleading.
>
>./heLen
>
>
Thank you Helen. I just started using Firebird recently but I already
noticed how invaluable your help in this forum is. I just purchased
your book and I am sure it will be an worthwhile investment. This is
probably the most massive computer book I own :-)

Avi