logo
Using Exist and All Quantification < TMQL Introduction < < Home 

PrevUpNext

Using Exist and All Quantification

On some occasions you will have to test whether particular things exists in a map or whether all things in certain set have a particular property. For illustration, let us ask for all music groups in our map which have at least one female group member

for $group in // group
where
    some $person in $group <- whole -> member
         satisfy
             $person isa female
return
    ($group)
While we iterate over all groups in the map, we find for each such group all members using the path expression $group <- whole -> member. If only one satisfies the condition that it is an instance of female then the existential SOME clause is satisfied.

Conversely, we might be interested to find all boy groups, well, at least those groups where all members are male:

for $group in // group
where
    every $person in $group <- whole -> member
         satisfies
             $person isa male
return
    ($group)