Toad World Blog

How to add Parent Table Name to FK columns at once

Dec 20, 2013 11:59:00 AM by Vaclav Frolik

There can be various reasons why all primary key attributes in your database structure should be named identically. 
The most typical name is "ID". But what if you start creating relationships?

In Toad Data Modeler all FK attributes are created automatically in child tables and because the names migrate as well, manual corrections might be necessary.

The following screenshot shows a sample of database structure where ID columns represent primary keys (in red) or foreign keys (in green).

id_01.png-550x0

All the foreign keys were added to child entities automatically and in many of the tables there are identically named attributes. Of course, this problem can be solved elegantly in Toad Data Modeler via Model Verification and the Quick Fixes feature that adds numbers/increments to the identically named objects.

In case you want to use parent entity name instead of numbers/increments do the following:

Download and install the Rename FK Columns package, restart Toad Data Modeler and then:

Select one or more relationships and choose Macros | Rename FK Column item to modify FK Column in child entity:

7875.id_02.png-550x0

Or click Macros | Rename FK Column to modify all FK Column names in your model.

id_04.png-550x0

Result is displayed on the last screenshot.

id_05.png-550x0

Note: The macro adds Parent Entity Caption to FK Attribute Caption and Parent Entity Name to FK Attribute Name. 
You can switch between Caption and Names using combo box in Toolbar.

Good Luck!

Tags: Toad Data Modeler Data Modeling

Vaclav Frolik

Written by Vaclav Frolik

Interests:

  • UX design and graphics
  • Databases
  • Product / Project management
  • Web technologies
  • Online marketing

Favorites:

  • Music bands: Pearl Jam, Audioslave, RHCP, Midnight Oil, Alter Bridge...
  • Actors: Kevin, Edward, Jack, Jeff and my kids.
  • Actresses: Kim, Jennifer
  • Sports: MTB, Squash, Football (the one played with feet, not hands)
  • Series: IT Crowd, The Big Bang Theory