Author Topic: How to get join data from DDL package?  (Read 4281 times)

Petr Sobotka

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
How to get join data from DDL package?
« on: March 04, 2012, 06:37:36 am »
Hi,

in my new addin (for EA 8) I would like to be able to somehow get data about how the tables from a DDL package are linked. I am already able to identify both needed tables and connectors, however not the columns through which one could join the tables. It is kinda frustrating, because in the DDL diagram I can see them in the label of the connector as "(column1 = column2)", but can't find a way to access them through Automation Interface  :-? .

In example let's say I have Table1 and Table2 where Table1 has "1 to many" association with Table2 enforced by FK. And I would like to be able to generate something like: Table1 inner join Table2 on Table1.xID = Table2.yID .

Is that possible and, if so, how?

Thx in advance

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to get join data from DDL package?
« Reply #1 on: March 05, 2012, 08:02:13 pm »
Isn't that just stored in the name?

Geert

Petr Sobotka

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: How to get join data from DDL package?
« Reply #2 on: March 05, 2012, 09:37:53 pm »
Quote
Isn't that just stored in the name?

Geert
Hi Geert,

at first I thought so too - even in XMI export it is in the name of the connector

however in the DDL diagram when you click properties on the connector there is no name and also connector.Name in the C# code returns empty string  :o

Isn't there a way (maybe via a querry) to access FKs of the given connector? ... in the DDL diagram on that connector I can see FKs through the context menu with the correct columns - I just don't know how to get there via C# code

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to get join data from DDL package?
« Reply #3 on: March 05, 2012, 09:41:35 pm »
Then we are looking at a different type of diagram, because on my diagram (reversen engineered database from SQL Server ) the name of the connector is (<FK field name> = <PK field name>) which is what you need for building joins.

Geert


Petr Sobotka

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: How to get join data from DDL package?
« Reply #4 on: March 05, 2012, 09:54:21 pm »
Quote
Then we are looking at a different type of diagram, because on my diagram (reversen engineered database from SQL Server ) the name of the connector is (<FK field name> = <PK field name>) which is what you need for building joins.

Geert

Well - mine was transformed from a PIM (EA version 8), when I get home I will try to play a bit with it if it is just some issue with the tranformation

Anyway - I saw you had some experience with SQL querrying of the Repository - don't you plz know a way to get foreign key data when you have the connector's ID that way? (This is my first attempt at EA plugin so I am still swimming a bit  :) )

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to get join data from DDL package?
« Reply #5 on: March 05, 2012, 10:49:48 pm »
It looks (on my model) like the foreign key's are operations defined on the element.
If you have a connector then that has a source/target name. That seems to correspond to the actual FK operation on the table. You should be able to find the table element based on the ClientID/SupplierID
The actual columns of the FK seem to be stored as parameters.

Geert

Petr Sobotka

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: How to get join data from DDL package?
« Reply #6 on: March 07, 2012, 08:05:07 am »
OK, so I was getting angry because, no matter how I did it, the manual transformation of my PIM package into DDL package produced an incomplete result - by accessing it both from EA and my code I found out that, for example, names of connectors were missing. However in the exported XMI of the DDL package everything seemed to be OK

So I exported the incomplete one and imported it back and voila - everything is as it should be and my code is now working and producing correct joins.  :)

It is a solution, albeit irking one - I'll probably look into ways to make it more elegant, but right now I'm glad it at least works. Anyways - big thanks to Geert for making me aware that the problem was with the result of transformation from PIM to DDL.
« Last Edit: March 07, 2012, 08:09:19 am by Sobocz »