<aggregate alias="TemplateVars" class="modTemplateVar" local="id:template" foreign="contentid:templateid" cardinality="many" owner="local" />
This question has been answered by opengeek. See the first response.
<composite alias="PropertySets" class="modElementPropertySet" local="id" foreign="element" owner="local" cardinality="many">
<criteria target="foreign"><![CDATA[
{"element_class":"modPlugin"}
]]></criteria>
</composite>
. It adds an extra criteria just like in the example for the join. Great when having same table for many object types so you can have query with "join something on local.id = foreign.id [b]AND foreign.element_class = 'modPlugin'". Best to try it out yourself
foreign for the extra definition comes from the target attribute. Also any valid JSON array should work but would guess no one has tried it 
foreach ($fkMeta['criteria']['foreign'] as $critKey => $critVal) {
if (is_numeric($critKey)) {
$foreignCriteria[] = $critVal;
} else {
$foreignCriteria["{$parentAlias}.{$critKey}"] = $critVal;
}
}
Checking at the modx schema to see how it is built i found this uncommon form:
<aggregate alias="TemplateVars" class="modTemplateVar" local="id:template" foreign="contentid:templateid" cardinality="many" owner="local">
What does it means when you use id:template and contentid:templateid?
Almost any other relation uses single field names.</aggregate>