I want an SQL query to get the list of object names in a specific diagram of Enterprise Architect.
My target Diagram_ID is 184
Elements are stored in t_object
and diagram objects (the graphical representation of one element in one diagram) in t_diagramobjects
. An entry in t_diagramobjects
has a reference to the diagram (Diagram_ID
) and to the element being displayed (Object_ID
).
t_object table
: has columns Object_ID
and Name
t_diagramobjects
table: has columns Object_ID
and Diagram_ID
If I do:
select Object_ID from t_diagramobjects where Diagram_ID=184
I get the list of Object_ID
s but I need the names. I want a query involving t_object
table to get the names.
EDIT: Rereading your question, seems like you do not know about join.
Here is a link (Assuming SQL Server again): https://www.w3schools.com/sql/sql_join.asp
Another EDIT
Here is more detail about why a normal join
does not work.
You can have your ea project in the form of a local file or in a database. When stored in a local file, it is stored as a MS Access database. MS Access does not support the join
keyword alone, you need to put either inner join
, outer join
, left join
, right join
...
And for those that do not know, you can run SQL queries in a local file project by creating a new search as a SQL Query.
Diagram Objects represent the Visual elements you see on the diagrams. The table t_object contains the elements in the repository, so you can make a simple join with the OBJECT_ID column.
This query should work on an access database (.eap file) as well as on a SQL Server database:
select o.name from t_object o
inner join t_diagramobjects do
on do.Object_ID=o.Object_ID
where do.Diagram_ID=184