# Removing a relation leaving its fields in the child table

**URL:** <https://forums.toadworld.com/t/removing-a-relation-leaving-its-fields-in-the-child-table/39209>\
**Category:** Toad Data Modeler\
**Created:** [March 15, 2017, 2:17am UTC](https://forums.toadworld.com/t/removing-a-relation-leaving-its-fields-in-the-child-table/39209 "2017-03-15T02:17:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tommaso\_Sala](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/tommaso_sala/32/11021_2.png) [@Tommaso\_Sala](https://forums.toadworld.com/u/Tommaso_Sala)\
**Post date:** [March 15, 2017, 2:17am UTC](https://forums.toadworld.com/t/removing-a-relation-leaving-its-fields-in-the-child-table/39209/1 "2017-03-15T02:17:21Z")

</div>

Hi,

I'm trying to remove a relation from my ERD, but I want to leave its carried fields in the child table.

In particular, I want to remove the relationship M20\_PCL\_F01 between parent M20\_PCL\_IDX and child M20\_PCL, but maintaining the field PCL\_ID in the child (highlighted in the image).

Whenever I remove the relation, Toad automatically removes the field too.

Is there any solution? (besides re-adding the field manually... it is inherited by a number of descendant tables)

 ![toad.jpeg](https://global.discourse-cdn.com/quest/original/2X/d/da50b37f16483a94614206586e7101649dda333d.jpeg)

---

<div class="post-metadata">

**Author:** ![Daril](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/daril/32/31_2.png) [@Daril](https://forums.toadworld.com/u/Daril)\
**Post date:** [March 15, 2017, 8:44am UTC](https://forums.toadworld.com/t/removing-a-relation-leaving-its-fields-in-the-child-table/39209/2 "2017-03-15T08:44:54Z")

</div>

Hi,

standard behavior is that attribute, which has been created by relationship(by migrating form parent entity) will be delete, when relationship is delete.

Is there way how to change this by Macro. Each attribute has internal property "KeepForeignKey". When this property is true, attribute preserve after delete relationship.

I wrote simple macro for you, it set "KeepForeignKey" for selected attributes. Package is created for version Toad Data Modeler 6.1.

Please copy this package to location "Path to Packages" (To show this tab in settings you need switch on Expert mode from Options-General) and start TDM. (You can use function "Import Custom Package" from Main Menu - Expert Mode - Customization).

 ![PathToPackages.png](https://global.discourse-cdn.com/quest/original/2X/e/e1156cd645fe3d859b186c4b6819e4474048d0ba.png)

Now when you right click on attribute in Model Explorer you will see new popup item "Keep Attribute"

![KeepForeignAttributeMacro.png](https://global.discourse-cdn.com/quest/original/2X/c/c77127f8249d61b17e23993e087179115f0dfd06.png)

Code of Macro is very simple, you can see it. If you want you can create easy macro to modify all attributes in model.

Regards

Daril  
[KeepForeignKeyMacro.zip](https://forums.toadworld.com/uploads/default/original/2X/b/b6ae52d7efb8b28deb71b1264c98e7f24360673f.zip) (1.14 KB)

---

<div class="post-metadata">

**Author:** ![Tommaso\_Sala](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/tommaso_sala/32/11021_2.png) [@Tommaso\_Sala](https://forums.toadworld.com/u/Tommaso_Sala)\
**Post date:** [March 16, 2017, 2:00am UTC](https://forums.toadworld.com/t/removing-a-relation-leaving-its-fields-in-the-child-table/39209/3 "2017-03-16T02:00:45Z")

</div>

Thanks, it worked.

I modified the _ **Attribute Properties** _ form to easily show and change the field:

![Visualizzazione di image.png](https://mail.google.com/mail/ca/u/1/?ui=2&ik=8723eea1b1&view=fimg&th=15ad2fb9ce7ea8cb&attid=0.1&disp=emb&realattid=ii_15ad2fb460c5db9e&attbid=ANGjdJ9w6iQGjBo5U036fKOcbQ3g-mYYTmyXqSkhdQIOE3giOEjhAvogv_wsOa51gHwknh_vheEme53PwW579DZKGtM8sJ-3rLBJwDi5w25utOL1WvZAFbv1GwwZ5ms&sz=w1088-h484&ats=1489654790626&rm=15ad2fb9ce7ea8cb&zw&atsh=1)

It would be nice to have it as a native option in Toad.

---

<div class="post-metadata">

**Author:** ![Daril](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/daril/32/31_2.png) [@Daril](https://forums.toadworld.com/u/Daril)\
**Post date:** [March 16, 2017, 11:28pm UTC](https://forums.toadworld.com/t/removing-a-relation-leaving-its-fields-in-the-child-table/39209/4 "2017-03-16T23:28:49Z")

</div>

Hi,

I created post on Idea Pond

[http://www.toadworld.com/products/toad-data-modeler/i/modeling/keep\_attribute\_migrated\_by\_relationship](http://www.toadworld.com/products/toad-data-modeler/i/modeling/keep_attribute_migrated_by_relationship)

Daril

---

<div class="post-metadata">

**Author:** ![Tommaso\_Sala](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/tommaso_sala/32/11021_2.png) [@Tommaso\_Sala](https://forums.toadworld.com/u/Tommaso_Sala)\
**Post date:** [March 17, 2017, 1:45am UTC](https://forums.toadworld.com/t/removing-a-relation-leaving-its-fields-in-the-child-table/39209/5 "2017-03-17T01:45:31Z")

</div>

Thanks.

I’m trying to accept your answer but when I click on Yes (Did this answer your question?) the page is simply reloaded and the question remain marked as not answered .
