Book a Demo

Author Topic: SQL Search on unassigned elements?  (Read 3136 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
SQL Search on unassigned elements?
« on: March 24, 2020, 03:23:44 am »
Hi

I'm working on an Archimate model with Application Components linked to Business Services via a Serving association.

A simple SQL Search lists all application/service links:
Code: [Select]
SELECT t_object.ea_guid AS CLASSGUID, t_object.Object_Type AS CLASSTYPE, t_object.Name AS 'Application'
, bizservice.Name AS 'Service'
FROM ((t_object inner join t_connector on t_object.Object_ID = t_connector.Start_Object_ID) 
inner join t_object bizservice on bizservice.Object_ID = t_connector.End_Object_ID)   
WHERE t_object.Stereotype = 'ArchiMate_ApplicationComponent'
and bizservice.Stereotype = 'ArchiMate_BusinessService'
and t_connector.Stereotype = 'ArchiMate_Serving'

I'm having issues in finding a proper to list all the applications that do not have any serving stereotyped connector to a stereotyped business service.

The following is incorrect as it only find applications that are not linked with anything

Code: [Select]
SELECT t_object.ea_guid AS CLASSGUID, t_object.Object_Type AS CLASSTYPE, t_object.Name AS 'Application'
FROM (t_object left join t_connector on t_object.Object_ID = t_connector.Start_Object_ID) 
WHERE t_object.Stereotype = 'ArchiMate_ApplicationComponent'
and t_connector.Start_Object_ID is null

I'm not sure there's a suitable query. Any hint?
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: SQL Search on unassigned elements?
« Reply #1 on: March 24, 2020, 03:58:57 am »
I would use a
where o.ObjectID not in (select ... [put here the query that returns the objects that are linked])

Another solution would be to do a left join with a subquery that joins t_connector and t_object as target

Geert

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: SQL Search on unassigned elements?
« Reply #2 on: March 24, 2020, 05:51:05 pm »
Hi Geert,

Your first suggestion worked perfectly.

Thanks !  ;D
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com