# How to change the displayed caption of for FK relationships in the Physical Model layout?

**URL:** <https://forums.toadworld.com/t/how-to-change-the-displayed-caption-of-for-fk-relationships-in-the-physical-model-layout/34427>\
**Category:** Toad Data Modeler\
**Created:** [November 4, 2015, 10:15am UTC](https://forums.toadworld.com/t/how-to-change-the-displayed-caption-of-for-fk-relationships-in-the-physical-model-layout/34427 "2015-11-04T10:15:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anieves13](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@anieves13](https://forums.toadworld.com/u/anieves13)\
**Post date:** [November 4, 2015, 10:15am UTC](https://forums.toadworld.com/t/how-to-change-the-displayed-caption-of-for-fk-relationships-in-the-physical-model-layout/34427/1 "2015-11-04T10:15:20Z")

</div>

I reversed engineered a database and it is displaying the caption “FK\_[parent table name]_to_[child\_table\_name]”. I would like the caption to display "[parent table name]:[column name]-[child table name]:[column name].

Is there any way I can do this without manually editing all the captions?

Thank you

---

<div class="post-metadata">

**Author:** ![Lukas.Knapek](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/lukas.knapek/32/269_2.png) [@Lukas.Knapek](https://forums.toadworld.com/u/Lukas.Knapek)\
**Post date:** [November 5, 2015, 4:11am UTC](https://forums.toadworld.com/t/how-to-change-the-displayed-caption-of-for-fk-relationships-in-the-physical-model-layout/34427/2 "2015-11-05T04:11:28Z")

</div>

Hello there,

The fastest way is to use a macro, please try executing the one I enclosed in **Expert Mode Menu** | **Scripting Window** (you need to enable **Expert Mode** in **Settings Menu** | **Options** | **General** ). It should rename all of your FKs in the model according to the pattern you mentioned.

Regards,

Lukas  
[RenameForeignKeys.txt](https://global.discourse-cdn.com/quest/original/2X/3/3e26a706cb4080f94ffbbe202d549f9c980a7816.txt) (1.26 KB)

---

<div class="post-metadata">

**Author:** ![anieves13](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@anieves13](https://forums.toadworld.com/u/anieves13)\
**Post date:** [November 6, 2015, 11:06am UTC](https://forums.toadworld.com/t/how-to-change-the-displayed-caption-of-for-fk-relationships-in-the-physical-model-layout/34427/3 "2015-11-06T11:06:01Z")

</div>

Thank you for the script. It was very valuable.

The script changed the caption but inside the entity. I used it as a reference to change the relation caption. I’m including the modified script that worked for me but my database foreign keys only have one column for each table. I don’t think my script would work otherwise.

function main() {  
var x, y, iterRel, childEntityName, parentEntityName, newCaption;

```
for (x = 0; x < Model.Relations.Count; x++) {
    iterRel = Model.Relations.GetObject(x);

    childEntityName = iterRel.ChildEntity.name;
    parentEntityName = iterRel.ParentEntity.name;

    for (y = 0; y < iterRel.ForeignKeys.Count; y++) {
        foreignKey = iterRel.ForeignKeys.GetObject(y);

        newCaption = "[" + parentEntityName + "-" + foreignKey.AttrParent.name + "]" + ":" + "[" + childEntityName + "-" + foreignKey.AttrChild.name + "]";

        //Log.Information(newCaption);
    }

    iterRel.caption = newCaption;
}

Model.RefreshModel();

```

}
