Toad World® Forums

Compound Foreign Key


#1

Can someone help me. I’m trying to create a compound foreign key in Toad Data Modeller.

We need to create a relationship between an account number/sub account number on one table with a single field containg both on another table thus:

TAB1.SUB_ACC_NO = TAB2.ACCNO | |LOAN_NO

ie 12345601 = 123456 || 01

In TDM I only seem to be able to select one field on each side of the relationship even though the help file says that compound keys are possible:

“In Toad Data Modeler, you can control your foreign keys. Foreign keys mapping feature allows you to create Compound Keys, use existing keys etc.”

Can someone advise if and how this is possible?

Many thanks,

Dave


#2

Please see if this is what you are after. First, I create two tables. Entity1 with columns ACCNO and LOAN_NO (both marked as PK), Entity2 with column SUB_ACC_NO. Then I create a relationship from Entity1 to Entity2. Immediately TDM will add two new columns (ACCNO and LOAN_NO). To change this, double click on the relationship line and go to Foreign Keys tab. Now hit F2 key and change Child to SUB_ACC_NO for both parent (ACCNO and LOAN_NO). Save the changes and you should have the compound key.

[cid:image001.png@01CB69F6.82AE8DA0]


#3

Thanks Frahuang

That was what we were after.

Cheers.