Poor FOREIGN KEY Constraint-Declaration-Implementation in Informix
Posted in 1993
Hello YOU out there,
for a moment give me your ear (I mean your eyes).
I have a problem with the Implementation of the declaration of
FOREIGN KEY constraints in Informix.
For composed keys I think that the implementation is *very poor* because
the order of the reference clause seems to be important. It seems that this
order has to match the order of the Primary Key definition although there is
no real need for this.
Example:
========
CREATE TABLE t1 ( a integer, b, integer, ...);
ALTER TABLE t1 ADD CONSTRAINT PRIMARY KEY (a,b);
Well, when I create Table t2, I know that my column c references column b of t1
and column d references a of t1 ( but at that time I do *not know the order* of
the columns in the Primary Key Constraint at that time, because it is not
important as it is only a detail of implementing t1 ).
CREATE TABLE t2 ( c integer, d integer, ...);
ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY (c,d) REFERENCES t1 (b,a);
This delivers me an error because in the Reference-clause (b,a) are in a
different order than (a,b) in the PRIMARY KEY constraint.
Why? Shouldn't Informix be able to transform this internally?!
In my statement I implicitely stated that c references b and d references a!
So my declaration is absolutely complete and clear.
Environment: Informix 5.0 on SunOS 4.1.2
Is this a known bug or (what would be even worse) the normal behaviour ??
If a bug, is it resolved in later revisions?
Do other RDBMS have the same problem?
Thanks for any comments.
Achim
--
==========================================================================
/ Achim Reiners Software Engineering \\
| /M/A/I Deutschland GmbH |
| Softwarezentrum Koeln Phone: +49 221 956400-40 |
| Mathias-Brueggen-Str. 85 Fax: +49 221 956400-69 |
\\ 50829 Koeln E-Mail: ar@mai.de /
\\_________________________________________________________________________/