-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJeanBanzekulivakha_Assesment3_Basic
130 lines (92 loc) · 2.95 KB
/
JeanBanzekulivakha_Assesment3_Basic
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
## 1. Get all the classes
SELECT *
WHERE {
?class a rdfs:Class
}
## 2. Get all the subclasses of the class Establishment
SELECT *
WHERE {
?subClass rdfs:subClassOf <http://GP-onto.fi.upm.es/exercise2#Establishment>
}
## 3. Get all instances of the class City
PREFIX ex1: <http://GP-onto.fi.upm.es/exercise2#>
SELECT *
WHERE {
?classCity a/rdfs:subClassOf* ex1:City
}
## 4. Get the number of inhabitants of Santiago de Compostela
PREFIX ex1: <http://GP-onto.fi.upm.es/exercise2#>
SELECT *
WHERE {
ex1:Santiago_de_Compostela ex1:hasInhabitantNumber ?numInhabitant
}
## 5. Get the number of inhabitants of Santiago de Compostela and Arzua
PREFIX ex1: <http://GP-onto.fi.upm.es/exercise2#>
SELECT *
WHERE {
{ ex1:Santiago_de_Compostela ex1:hasInhabitantNumber ?numInhabitant }
UNION
{ ex1:Arzua ex1:hasInhabitantNumber ?numInhabitant }
}
## 6. Get all places, together with the number of inhabitants, ordered by the place name (ascending)
PREFIX ex1: <http://GP-onto.fi.upm.es/exercise2#>
SELECT *
WHERE {
OPTIONAL{ ?place ex1:hasInhabitantNumber ?numInhabitant }
}
ORDER BY ASC(?place)
## 7. Get all instances of Locality together with their number of inhabitants (if this information exists)
PREFIX ex1: <http://GP-onto.fi.upm.es/exercise2#>
SELECT ?place ?numInhabitant
WHERE {
?loc rdfs:subClassOf* ex1:Locality .
?place a ?loc .
OPTIONAL{ ?place ex1:hasInhabitantNumber ?numInhabitant }
}
## 8. Get all places with more than 200.000 inhabitants
PREFIX ex1: <http://GP-onto.fi.upm.es/exercise2#>
SELECT *
WHERE {
OPTIONAL{ ?place ex1:hasInhabitantNumber ?numInhabitant }
FILTER (xsd:integer(?numInhabitant) > "200000"^^<http://www.w3.org/2001/XMLSchema#integer>)
}
## 9. Get postal address data for Pazo_Breogan (street, number, locality, province)
PREFIX ex1: <http://GP-onto.fi.upm.es/exercise2#>
SELECT ?street ?number ?locality ?province
WHERE {
ex1:Pazo_Breogan ex1:hasAddress ?address .
?address ex1:hasStreet ?street .
?address ex1:hasNumber ?number .
ex1:Pazo_Breogan ex1:isPlacedIn ?locality .
?locality ex1:inProvince ?province
}
## 10. Get all subclasses of class Location
PREFIX ex1: <http://GP-onto.fi.upm.es/exercise2#>
SELECT *
WHERE {
?subClass rdfs:subClassOf* ex1:Location
}
## 11. Get all instances of class Locality
PREFIX ex1: <http://GP-onto.fi.upm.es/exercise2#>
SELECT *
WHERE {
?instance a/rdfs:subClassOf* ex1:Locality
}
## 12. Describe the resource with rdfs:label "Madrid”
DESCRIBE ?res
WHERE
{
?res rdfs:label "Madrid".
}
## 13. Construct a graph that relates directly all touristic places with their provinces, using a new property called ”isIn”
PREFIX ex1: <http://GP-onto.fi.upm.es/exercise2#>
CONSTRUCT { ?place ex1:isIn ?province }
WHERE {
?place a/rdfs:subClassOf* ex1:TouristicLocation .
OPTIONAL { ?place ex1:isPlacedIn/ex1:inProvince ?province }
}
## 14. Check whether there is any instance of Town
PREFIX ex1: <http://GP-onto.fi.upm.es/exercise2#>
ASK {
?instance a ex1:Town
}