Toad World® Forums

relationships, foreign key

I am trying to connect the tables. one table has business_id, business_name and state_id, the other table has state_id and state name. When I try and connect the two by state_id it creates a new attribute called business_id in the second table. I want state_id to be a foreign key in both. What do I need to do? Thanks.

Hi,

I presume that business_id from the parent table is primary key so you have to create a new alternative key for state_id. state_id. If you create a new relationships from business table to state table it automatically maps existing attribute and creates a new foreign key "state_id" in the state table. You can also map attributes manually or change the linking method in relationship properties.

Regards,

David

If David’s guidance didn’t solve your problem, here’s another possibility.

  1. Delete the state_id attribute in the business table.

  2. Confirm that state_id is tagged as the primary key in the state table. You should

see the PK key icon next to it. If it isn’t, edit the state_id attribute and check

the Primary key indicator.

  1. Draw the relationship from the state table to the business table.

The state_id should appear as a new attribute in the business table.

(It sounds like you originally drew the relationship line from the business

table to the state table, and the business id showed up in the state table–and

you didn’t want that.)

Mike