Skip to content
Browse files
add example for Optionals Order Dependent Queries in sparql tutorial (#…
  • Loading branch information
LeonPoon committed May 16, 2021
1 parent 23d0541 commit 32c40684d07ce7acc2821ef21b17d469039c2f53
Showing 1 changed file with 50 additions and 2 deletions.
@@ -146,11 +146,59 @@ more optional clauses (and not in some basic pattern as well):

If the first optional binds `?name` and `?x` to some values, the
second `OPTIONAL` is an attempt to match the ground triples (`?x`
and `<kbd>?name</kbd>` have values). If the first optional did not
and `?name` have values). If the first optional did not
match the optional part, then the second one is an attempt to match
its triple with two variables.

With an example set of data in which every combination of values exist:


<!-- both vCard:FN and foaf:name have values, and the values are the same -->
<foaf:Person rdf:about="http://somewhere/JohnSmith">
<vCard:FN>John Smith</vCard:FN>
<foaf:name>John Smith</foaf:name>

<!-- both vCard:FN and foaf:name have values, but the values are not the same -->
<foaf:Person rdf:about="http://somewhere/RebeccaSmith">
<vCard:FN>Becky Smith</vCard:FN>
<foaf:name>Rebecca Smith</foaf:name>

<!-- only vCard:FN has values -->
<foaf:Person rdf:about="http://somewhere/SarahJones">
<vCard:FN>Sarah Jones</vCard:FN>

<!-- only foaf:name has values -->
<foaf:Person rdf:about="http://somewhere/MattJones">
<foaf:name>Matthew Jones</foaf:name>

<!-- neither vCard:FN nor foaf:name have values -->
<foaf:Person rdf:about="http://somewhere/AdamJones" />


Executing the above query will yield these solutions:

| name |
| "John Smith" |
| "Matthew Jones" |
| "Sarah Jones" |
| |
| "Rebecca Smith" |

[Next: union queries](sparql_union.html)

0 comments on commit 32c4068

Please sign in to comment.