#278 Allow for several foreign key constraints on the same column

open
nobody
engine (144)
5
2012-04-06
2012-04-06
Lukas Eder
No

This is a minor "feature" or improvement. I've noticed by accident, that the following is possible in most databases except HSQLDB:

------------------------------------------------------------
CREATE TABLE test (
ID INT NOT NULL,
FK_ID INT,

CONSTRAINT pk_test PRIMARY KEY(ID),
CONSTRAINT fk_test_a FOREIGN KEY(FK_ID) REFERENCES some_table(ID),
CONSTRAINT fk_test_b FOREIGN KEY(FK_ID) REFERENCES some_table(ID),
)
------------------------------------------------------------

This is a useless example, of course, but if the same column would reference several tables, it might become useful. I've checked the above statement against any of these databases:

- CUBRID
- DB2
- Derby
- H2
- Ingres
- MySQL
- Oracle
- Postgres
- SQL Server
- SQLite
- Sybase SQL Anywhere
- Sybase ASE

Discussion

  • Fred Toussi
    Fred Toussi
    2012-05-13

    I don't think I wouldl support this. Although it is not disallowed by the standard, it serves no purpose.