forked from FacultadInformatica-LinkedData/Curso2016-2017
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVictorViller-SPARQL_Questionnaire-BASIC.txt
84 lines (56 loc) · 2.86 KB
/
VictorViller-SPARQL_Questionnaire-BASIC.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
1. Get all the classes
SELECT DISTINCT ?c WHERE { ?s a ?c }
2. Get all the subclasses of the class Establishment
SELECT DISTINCT ?sc WHERE { ?sc rdfs:subClassOf <http://GP-onto.fi.upm.es/exercise2#Establishment> }
3. Get all instances of the class City
SELECT DISTINCT ?i WHERE { ?i a <http://GP-onto.fi.upm.es/exercise2#City> }
4. Get the number of inhabitants of Santiago de Compostela
PREFIX ciudad:<http://GP-onto.fi.upm.es/exercise2#>
SELECT DISTINCT ?n WHERE { ciudad:Santiago_de_Compostela ciudad:hasInhabitantNumber ?n }
5. Get the number of inhabitants of Santiago de Compostela and Arzua
PREFIX ciudad:<http://GP-onto.fi.upm.es/exercise2#>
SELECT DISTINCT COUNT(?n) ?n WHERE { {ciudad:Santiago_de_Compostela ciudad:hasInhabitantNumber ?n}
UNION {ciudad:Arzua ciudad:hasInhabitantNumber ?n} }
6. Get all places, together with the number of inhabitants, ordered by the place name (ascending)
PREFIX ciudad:<http://GP-onto.fi.upm.es/exercise2#>
SELECT DISTINCT ?lugar ?n WHERE { ?lugar ciudad:hasInhabitantNumber ?n } ORDER BY ASC(?lugar)
7. Get all instances of Locality together with their number of inhabitants (if this information exists)
PREFIX ciudad:<http://GP-onto.fi.upm.es/exercise2#>
SELECT DISTINCT ?lugar ?valores ?n WHERE
{ {?lugar a ?valores .
?valores rdfs:subClassOf ciudad:Locality} .
OPTIONAL {?lugar ciudad:hasInhabitantNumber ?n} }
8. Get all places with more than 200.000 inhabitants
PREFIX ciudad:<http://GP-onto.fi.upm.es/exercise2#>
SELECT DISTINCT ?lugar ?n WHERE
{ ?lugar ciudad:hasInhabitantNumber ?n .
FILTER (xsd:integer(?n) > 200000) }
9. Get postal address data for Pazo_Breogan (street, number, locality, province)
PREFIX ciudad:<http://GP-onto.fi.upm.es/exercise2#>
SELECT DISTINCT ?street ?number ?locality ?province WHERE
{ ciudad:Pazo_Breogan ciudad:hasAddress ?direccion .
?direccion ciudad:hasStreet ?street .
?direccion ciudad:hasNumber ?number .
ciudad:Pazo_Breogan ciudad:isPlacedIn ?locality .
?locality ciudad:inProvince ?province }
10. Get all subclasses of class Location
PREFIX ciudad:<http://GP-onto.fi.upm.es/exercise2#>
SELECT DISTINCT ?sc WHERE
{ ?sc rdfs:subClassOf ciudad:Location }
11. Get all instances of class Locality
PREFIX ciudad:<http://GP-onto.fi.upm.es/exercise2#>
SELECT DISTINCT ?i WHERE
{ ?i a ciudad:Locality }
12. Describe the resource with rdfs:label "Madrid”
PREFIX ciudad:<http://GP-onto.fi.upm.es/exercise2#>
DESCRIBE ?r
WHERE { ?r rdfs:label "Madrid" }
13. Construct a graph that relates directly all touristic places with their provinces, using a new property called ”isIn”
PREFIX ciudad:<http://GP-onto.fi.upm.es/exercise2#>
CONSTRUCT {?t ciudad:isIn ?p} WHERE { {?t a ?sc .
?sc rdfs:subClassOf ciudad:TouristicLocation} .
?t ciudad:isPlacedIn ?l .
?l ciudad:inProvince ?p }
14. Check whether there is any instance of Town
PREFIX ciudad:<http://GP-onto.fi.upm.es/exercise2#>
ASK WHERE { ?res a ciudad:Town }