Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: msadauskas on May 12, 2023, 12:27:32 am

Title: Setting "Involved Columns" mapping on a foreign key connector from script
Post by: msadauskas on May 12, 2023, 12:27:32 am
Hi,

I am creating foreign key relations between two tables progamatically in Sparx EA (v15) using the scripting functionality.
Generally it seems to be working well, however, I cannot find a way to define the mapping between the columns of the connector ends.

I works well out of the box, if a PK consists only of single column.
If I have a PK with two columns and I reference it using a FK from other table, the mapping of the columns seems to behave rather inconsistent.

Is there a way how I can set the mapping explicitelly from the script either on the FK operation or the FK connector or somewhere else?
Basically I am searching for the funtcionality which, using the interface, can be done when you right click on connector and then select "Foreign Keys..." menu item.

Thanks!

Best regards,
Martin
Title: Re: Setting "Involved Columns" mapping on a foreign key connector from script
Post by: msadauskas on May 12, 2023, 02:54:20 am
It seems that I was able to solve the problem on my own after all.

The issue was the ordering of the parameter in the PK method on one side and the FK method on the other side. The order of the parameters has to match as it is used for the mapping.
Title: Re: Setting "Involved Columns" mapping on a foreign key connector from script
Post by: Paolo F Cantoni on May 12, 2023, 10:33:56 am
It seems that I was able to solve the problem on my own, after all.

The issue was the ordering of the parameter in the PK method on one side and the FK method on the other side. The order of the parameters has to match as it is used for the mapping.
Hi Martin,
While it might be argued that conceptually, the order of the key parameters in the base table and the columns in the child table is not relevant to either the development of the indexes or constraints so long as the mapping is defined, it is always best to make sure the two align.  The developers, both for Sparx and also probably the underlying DB technology, have probably assumed this.

Paolo