Author Topic: Setting "Involved Columns" mapping on a foreign key connector from script  (Read 1900 times)

msadauskas

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
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.
  • sometimes it does not show up in diagramm at all
  • sometimes the columns mapped automatically but incorrectly
  • sometimes the columns are mapped automatically correctly

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

msadauskas

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
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.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
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
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!