Constraining the order of different properties
From RDF Data Shapes Working Group
Taking schema.org as an example, there are recurring patterns of relationships between multiple properties, possibly even at multiple related objects.
Example 1: schema:deathDate must be after schema:birthDate
In SPIN
schema:Person spin:constraint [ sp:text """ ASK WHERE { ?this schema:birthDate ?earlierDate . ?this schema:deathDate ?laterDate . FILTER (?earlierDate > ?laterDate) . } """ ] ; ...
Or using a SPIN template, where the body of the template is similar to the above query:
schema:Person spin:constraint [ a schemaspin:DatesMustBeOrdered ; arg:earlierProperty schema:birthDate ; arg:laterProperty schema:deathDate ; ]
The same template can then be reused in similar cases, such as schema:Event startDate/endDate.
Example 2: All children must be born after the parent.
In SPIN:
schema:Person spin:constraint [ sp:text """ ASK WHERE { ?this schema:birthDate ?parentBirthDate . ?this (schema:children)+ ?child . ?child schema:birthDate ?childBirthDate . FILTER (?parentBirthDate > ?childBirthDate) . } """ ] ;