The fragment always starts from the element.
The idea is to return all fields for all foreign keys in your table.
Here's a query I made to report on attributes.
select att.[Pos] AS Pos, att.[Name], att.Notes AS [Description-Formatted], att.LowerBound, att.UpperBound ,
CASE WHEN x.[Description] is null THEN 'no' ELSE 'yes' END AS IsID,
isnull(v.[Value], 'TBD') AS Versioned,isnull(dc.VALUE,'TBD') as DataClassification, isnull(ts.[Value], 'TBD') AS Timesliced, att.TYPE AS Format
from ((((t_attribute att
left outer join [t_attributetag] v on (v.[ElementID] = att.[ID]
and v.[Property] = 'Versioned'))
left outer join [t_attributetag] ts on (ts.[ElementID] = att.[ID]
and ts.[Property] = 'Timesliced'))
left outer join [t_attributetag] dc on (dc.[ElementID] = att.[ID]
and dc.[Property] = 'Atrias::Data Classification'))
left outer join t_xref x on (x.[Client] = att.[ea_guid]
and x.Type = 'attribute property'
and x.[Description] like '%@PROP=@NAME=isID@ENDNAME;@TYPE=Boolean@ENDTYPE;@VALU=1@ENDVALU;%'))
where att.Object_ID = #OBJECTID#
union all
select 0, 'N/A', 'This class has no specific attributes' AS [Description-Formatted], '', '',
'' AS IsID,
'' AS Versioned,'' as DataClassification, '' AS Timesliced, '' AS Format
where not exists
(select a.ID from t_attribute a where a.Object_ID = #OBJECTID#)
order by Pos
For operations that is pretty much similar.
Geert