Book a Demo

Author Topic: Aggrieved about aggregation using SQL queries  (Read 5262 times)

Colin Coates

  • EA User
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Aggrieved about aggregation using SQL queries
« on: April 20, 2023, 07:38:06 pm »
I am very surprised about needing to query for SubType is null in Aggregation relationships; surely it should either be 'Strong' or 'Weak'? Could this be a bug?

Code: [Select]
select Start_Object_ID from t_connector
where Connector_Type = 'Aggregation'
and SubType = 'Strong'
or SubType = 'Weak'
or SubType is null;

Colin Coates

  • EA User
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Re: Aggrieved about aggregation using SQL queries
« Reply #1 on: April 20, 2023, 08:08:17 pm »
Sorry, query should be:
Code: [Select]
select * from t_connector
where Connector_Type = 'Aggregation'
and (SubType = 'Strong'
or SubType = 'Weak'
or SubType is null);

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Aggrieved about aggregation using SQL queries
« Reply #2 on: April 20, 2023, 08:25:14 pm »
You shouldn't really be testing the subtype at all.

I usually only test DestIsAggregate or SourceIsAggregate. 1 => Aggregation, 2 => Composition

Code: [Select]
select * from t_connector c
where c.Connector_Type in ('Association', 'Aggregation')
and c.DestIsAggregate > 0 or c.SourceIsAggregate > 0

Geert

Colin Coates

  • EA User
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Re: Aggrieved about aggregation using SQL queries
« Reply #3 on: April 20, 2023, 08:35:05 pm »
Whilst I have no doubt your reasons are impeccable, I don't really get why testing the Subtype is such a bad thing (apart from the "is null" issue, of course)?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Aggrieved about aggregation using SQL queries
« Reply #4 on: April 20, 2023, 09:03:13 pm »
Whilst I have no doubt your reasons are impeccable, I don't really get why testing the Subtype is such a bad thing (apart from the "is null" issue, of course)?
Mainly because I want to know about all compositions or aggregations, not just the the "Aggregation" variant, but also the Association.

And UML doesn't know subtype strong/weak. It knows about AggregationKind on both ends being shared (1 in EA) or composite (2 in EA)

So the subtype is completely redudant and derived information, and I'm pretty sure even EA itself doesn't really use that field (hence the null values in there)

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Aggrieved about aggregation using SQL queries
« Reply #5 on: April 20, 2023, 09:10:27 pm »
AFAIR the aggregation underwent some change in the UML spec. Hence it's likely heritage.

q.

Colin Coates

  • EA User
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Re: Aggrieved about aggregation using SQL queries
« Reply #6 on: April 25, 2023, 06:41:59 pm »
Thanks for your comprehensive (if slightly unsettling) replies, Gentlemen!