Database Reference
In-Depth Information
in settlements with populations greater than 100), and the UNION keyword returns
results that match exactly one of the mutually exclusive graph patterns presented in
the where clause. For example, the following will return regions containing the city
of Medina or the village of Ash Fleet:
1. base < http://data.mereamaps.gov.me/administrativeRegions.rdf >
2. prefix admin: < http://data.mereamaps.gov.me/administrativeRegions/ >
3. select *
4. from < http://data.mereamaps.gov.me/administrativeRegions.rdf >
5. where
6. {
7. ?region :a admin:Region;
8. :contains ?y.
9. {
10. ?y a admin:City;
11.
admin:hasPlaceName 'Medina'.
12. }
13. union
14. {
15. ?y a admin:Village;
16.
admin:hasPlaceName 'Ash Fleet'.
17. }
18.}
Finally, we should mention the OPTIONAL keyword, which allows results to be
returned even if the part of the pattern within the optional clause is not matched. For
example, the following query will return regions that contain any city and will return
their names if the information is available:
1. base < http://data.mereamaps.gov.me/administrativeRegions.rdf >
2. prefix admin: < http://data.mereamaps.gov.me/administrativeRegions/ >
3. select *
4. from < http://data.mereamaps.gov.me/administrativeRegions.rdf >
5. where
6. {
7. ?region a admin:Region;
8. :contains ?y.
9. ?y a admin:City.
10. optional {?y ?hasPlaceName ?name.}
11. }
8.3.2 Q uerying M ultiple g raphS
The from clause used in the queries of Section 8.3.1 specifies what is known as the
background graph. We can, however, specify multiple RDF graphs to query, using
named graphs. We do this with the statement:
from named <uri>
Search WWH ::




Custom Search