query-40e6e3c66259c115226ea4d199419c5c
Battles of the Middle Ages in Europe
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#defaultView:Map
SELECT DISTINCT
?item
(SAMPLE(?item_label) AS ?battle)
(SAMPLE(?place_label) AS ?place_label)
(SAMPLE(?partOf_label) AS ?partOf_label)
(SAMPLE(?year) AS ?year)
(SAMPLE(?image) AS ?image)
(SAMPLE(?century) AS ?layer)
(SAMPLE(?coords) AS ?coords)
WHERE {
{
?item wdt:P31/wdt:P279* wd:Q178561 .
} UNION {
?item wdt:P31/wdt:P279* wd:Q188055 .
}
OPTIONAL {
?item rdfs:label ?item_label .
FILTER(LANG(?item_label) IN ('fr', 'en')) .
}
OPTIONAL {
?item wdt:P361 ?partOf .
?partOf rdfs:label ?partOf_label .
FILTER(LANG(?partOf_label) IN ('fr', 'en')) .
}
OPTIONAL { ?item wdt:P18 ?image . }
# Place
?item (wdt:P17|wdt:P276|wdt:P706|wdt:P131)*/wdt:P30 wd:Q46 .
?item wdt:P276 ?place .
OPTIONAL {
?place rdfs:label ?place_label .
FILTER(LANG(?place_label) IN ('fr', 'en')) .
}
# Coords
OPTIONAL { ?item wdt:P625 ?coordsItem . }
OPTIONAL { ?place wdt:P625 ?coordsPlace . }
BIND(COALESCE(?coordsItem, ?coordsPlace) AS ?coords)
# Date
?item (wdt:P585|wdt:P580|wdt:P582) ?date .
BIND(YEAR(?date) AS ?year) .
FILTER(?year >= 476) .
FILTER(?year <= 1492) .
BIND(FLOOR((?year - 1)/100)+1 AS ?century) .
} GROUP BY ?item ORDER BY ?year ?battle
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v15("?battle")
v14("?century"):::projected
v16("?coords"):::projected
v10("?coordsItem")
v11("?coordsPlace")
v13("?date")
v15("?image"):::projected
v6("?item"):::projected
v5("?item_label"):::projected
v15("?layer")
v7("?partOf")
v15("?partOf_label"):::projected
v9("?place")
v15("?place_label"):::projected
v15("?year"):::projected
a1((" "))
a2((" "))
a3((" "))
c17(["wd:Q46"]):::iri
c8(["wd:Q188055"]):::iri
c7(["wd:Q178561"]):::iri
f0[["?year <= '1492^^xsd:integer'"]]
f0 --> v15
f1[["?year >= '476^^xsd:integer'"]]
f1 --> v15
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P31"--> a2
a2 --"wdt:P279"--> c8
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c7
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v6 -."rdfs:label".-> v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v6 -."wdt:P361".-> v7
v7 --"rdfs:label"--> v15
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v6 -."wdt:P18".-> v15
end
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
subgraph union3[" Union "]
subgraph union3l[" "]
style union3l fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P131"--> a3
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P706"--> a3
end
union3r <== or ==> union3l
end
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P276"--> a3
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P17"--> a3
end
union1r <== or ==> union1l
end
a3 --"wdt:P30"--> c17
v6 --"wdt:P276"--> v9
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v9 -."rdfs:label".-> v15
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v6 -."wdt:P625".-> v10
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v9 -."wdt:P625".-> v11
end
bind2[/"?coordsItem?coordsPlace"/]
v10 --o bind2
v11 --o bind2
bind2 --as--o v16
subgraph union4[" Union "]
subgraph union4l[" "]
style union4l fill:#abf,stroke-dasharray: 3 3;
subgraph union5[" Union "]
subgraph union5l[" "]
style union5l fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P582"--> v13
end
subgraph union5r[" "]
style union5r fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P580"--> v13
end
union5r <== or ==> union5l
end
end
subgraph union4r[" "]
style union4r fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P585"--> v13
end
union4r <== or ==> union4l
end
bind3[/"year-from-dateTime(?date)"/]
v13 --o bind3
bind3 --as--o v15
bind4[/"numeric-floor(?year - '1^^xsd:integer' / '100^^xsd:integer') + '+1^^xsd:integer'"/]
v15 --o bind4
bind4 --as--o v14
bind12[/"sample(?item_label)"/]
v5 --o bind12
bind12 --as--o v15
bind13[/"sample(?place_label)"/]
v15 --o bind13
bind13 --as--o v15
bind14[/"sample(?partOf_label)"/]
v15 --o bind14
bind14 --as--o v15
bind15[/"sample(?year)"/]
v15 --o bind15
bind15 --as--o v15
bind16[/"sample(?image)"/]
v15 --o bind16
bind16 --as--o v15
bind17[/"sample(?century)"/]
v14 --o bind17
bind17 --as--o v15
bind18[/"sample(?coords)"/]
v16 --o bind18
bind18 --as--o v16