我使用 Sparx EA 构建关系数据库(MS SQL Server)。
该工具具有创建图表的功能。
我使用查询:
SELECT system.Name AS Series, systemElement.Name AS GroupName
FROM t_object systemElement
INNER JOIN t_object system ON system.Object_ID = systemElement.ParentID
INNER JOIN t_object organization ON organization.ParentID = systemElement.Object_ID
INNER JOIN t_object post ON post.ParentID = organization.Object_ID AND post.Stereotype = 'ActualPost'
WHERE system.Name = 'Name of my main system object'
要得到
这很好,只是因为图表没有说明 ActualPosts 的多样性。
我可以访问多样性
SELECT system.Name AS Series, systemElement.Name AS GroupName, post.Name AS 'ActualPost', post.Multiplicity AS 'Multiplicity'
FROM t_object systemElement
INNER JOIN t_object system ON system.Object_ID = systemElement.ParentID
INNER JOIN t_object organization ON organization.ParentID = systemElement.Object_ID
INNER JOIN t_object post ON post.ParentID = organization.Object_ID AND post.Stereotype = 'ActualPost'
WHERE system.Name = 'Name of my main system object'
结果如下表:
Series | GroupName | ActualPost | Multiplicity
Name of my main system element | OperationalPerformer A | Post AA | 1
Name of my main system element | OperationalPerformer A | Post AB | 1
Name of my main system element | OperationalPerformer A | Post AC | 2
Name of my main system element | OperationalPerformer B | Post BA | 1
Name of my main system element | OperationalPerformer B | Post BB | 1
Name of my main system element | OperationalPerformer C | Post CA | 3
Name of my main system element | OperationalPerformer C | Post CB | 2
Name of my main system element | OperationalPerformer C | Post CC | 5
我在想的是把多重性添加为行,所以把一张桌子变成这样:
Series | GroupName | ActualPost| Multiplicity
Name of my main system element | OperationalPerformer A | Post AA | 1
Name of my main system element | OperationalPerformer A | Post AB | 1
Name of my main system element | OperationalPerformer A | Post AC | 2
进入
Series | GroupName
Name of my main system element | OperationalPerformer A
Name of my main system element | OperationalPerformer A
Name of my main system element | OperationalPerformer A
Name of my main system element | OperationalPerformer A
虽然我不知道该怎么做。
有什么想法吗?
谢谢!
更新:
似乎 Sparx EA 在 SQL 查询方面有一些限制......查询必须以 select 开头,请参阅EA Sparx 查询中的 WITH 子句
提供的答案是否有解决方法?