logo
Association Templates < TMQL Introduction < < Home 

PrevUpNext

Association Templates

In the queries so far we made use of association templates. Writing inside a query

   is-produced-by (production : $album, producer: $producer)
makes the processor try to find matching associations in the queried map. Such associations must be of type is-produced-by and must have exactly two roles, one for production and one for producer. If an association in the map has a third role, say, location, to capture where an album has been produced, then such association would never match the template.

To allow for such associations with additional roles to match, TMQL allows to append an ellipsis:

select $album
where
   is-produced-by (production : $album, producer: $whoever, ...)

Association templates actually have more implicit meaning than is obvious at first sight. If, for example, the map contained an association of type is-remastered-by which also connects an album with a producer and is-remastered-by is a subtype of is-produced-by, then also such associations would match the template.

Honoring subclassing also applies to roles. Had we in our queried map an association of type is-remastered-by, but the role (type) for the album is not production, but the subclass remastering, such association would also match the association template.

If you would not care about the role, you can use a wildcard there:

select $album
where
   is-produced-by (production : $album, * : $whoever, ...)
The * is equivalent with xtm:subject. Obviously, everything in the map is an instance of a subject. Using such wildcards may be convient; it may also be walking on thin ice as processors have less knowledge to start with. This may make an impact on the performance.