Subject Re: [firebird-support] Re: Alternative for UNIQUE constraint
Author Helen Borrie
At 10:59 PM 28/03/2009, you wrote:
>Though the REFERENCE ... lines
>themselves never caused a problem when I tested my example...

I don't know what you tested it on.

>Anyway, I moved them out of the CREATE TABLE statements and put them
>into separate ALTER TABLE ... ADD FOREIGN KEY ... statements. That's
>what you meant by explicitly and not in the same transaction, right?

No and/or yes. ;-)

"Explicit" means you need to have the FOREIGN KEY token (in the right place, of course) - as opposed to "implicit" as in the transcript you supplied, i.e. just supplying a REFERENCES clause to a column definition.

But adding a FOREIGN KEY constraint involves dependencies, hence the advice to deal with FK constraints *after* the prime definitions have all been committed. Failing to do so doesn't cause it to bomb every time; but because it can cause it sometimes, good practice says "Pre-empt Murphy".

Or...live dangerously... :-D

./hb