Subject | Re: [ib-support] The dreaded foreign key creation error |
---|---|
Author | Helen Borrie |
Post date | 2002-01-03T15:36:50Z |
At 04:20 PM 03-01-02 +0100, you wrote:
:)
Helen
All for Open and Open for All
Firebird Open SQL Database ยท http://firebirdsql.org
_______________________________________________________
>Hi all,Well, you won't like it, probably..but my rule (incidentally NOT determined by the need to work around your problem, but by aesthetics) is to NEVER make a primary key do double action as a foreign key. If I want a foreign key, I create a column for it, i.e. design the database before you create it. It doesn't cost much and it keeps keys "functionally pure".
>
>Perhaps we all know the error:
>
>My metadata was this:
>
>Table "RELATIE"
>
>RelatieID PK
>... more columns ...
>
>Table "LEVERANCIER"
>
>RelatieID PK, FK to RELATIE
>... more columns ...
>
>Table "ORDERREGEL"
>
>LeverancierID FK to LEVERANCIER
>
>Creating this constraint gave me the error that some index wasn't defined in
>the tables and a trigger raised an exception bla bla...
>
>A common cause for this error is have an index defined on a primary key
>column. In this case, the index was created by the system - namely because
>of the FK from LEVERANCIER to RELATIE.
>
>Dropping this FK results in removing the index and the second FK (from
>ORDERREGEL to LEVERANCIER) could be created without problems. Next up:
>creating the FK from LEVERANCIER to RELATIE. All went well...
>
>It is a workaround for a strange problem -- comments, anyone?
:)
Helen
All for Open and Open for All
Firebird Open SQL Database ยท http://firebirdsql.org
_______________________________________________________