Subject Re: [firebird-support] How to create a foreign key that use an already existing index ?
Author Thomas Steinmaurer
> i often meet this scenario :
>
> CREATE TABLE MASTER(
> ID INTEGER NOT NULL,
> PRIMARY KEY (ID)
> );
>
> CREATE TABLE SLAVE(
> ID_MASTER INTEGER NOT NULL,
> PRIMARY KEY (ID)
> );
>
> ALTER TABLE SLAVE ADD FOREIGN KEY (ID_MASTER) REFERENCES MASTER (ID);
>
> the big problem is that i will have 2 INDEXES on the same field on the table Slave, one for the primary key and another for the foreign key, both exactly the same.
>
> is it possible to say to the foreign key to not create any index and use instead the index on the primary_key ?

The USING INDEX clause is your friend here: ;-)
http://www.firebirdsql.org/refdocs/langrefupd20-create-table.html#langrefupd20-ct-using-index


--
With regards,
Thomas Steinmaurer
http://www.upscene.com/