Toad World® Forums

Problem Mapping Keys

I have a compound primary key in my parent table that is composed of two fields.
In my child table I have a foreign key that corresponds to one of the two fields that form the compound primary key in the parent table. I want to create a relationship between the parent and child tables in which i join one field in my child table to the corresponding field in my parent table. However, the Data Modeler is forcing me to provide a corresponding field in my child table for BOTH of the fields in my primary table that make up the compound join. Can this be adjusted? Please help. Thank you.

This is the DDL being generated by Toad DM.

ALTER TABLE “cutoff_inventory_item” ADD CONSTRAINT “Relationship2” FOREIGN KEY (“cutoff_dt”, “cutoff_dt”) REFERENCES “cutoff_deal_item” (“cutoff_dt”, “deal_item_id”)

This is the DDL I ultimately want. Note that there is no join for deal_item_id.

ALTER TABLE “cutoff_inventory_item” ADD CONSTRAINT “Relationship2” FOREIGN KEY (“cutoff_dt”) REFERENCES “cutoff_deal_item” (“cutoff_dt”)

Message was edited by: HLHL


create new alternate key in parent table and add only the one attribute to it. Then draw relationship between the two tables, edit it and on tab Foreign Keys choose the alternate key instead of primary key.



I am wondering whether you have the modelingbackwards. We use this a lot, where thecompound PK is for a table that is a mapping between two other tables. There is a FK for each element of thecompound key to one of the other tables. You have two tables of objects. The map table shows which objects are related to each other.