query-3ad124e250015f2b4ffb0480dc714481
Queries and reportsAll constituencies used in a UK MP article (since 1801)
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?constituency ?constituencyLabel ?typeLabel ?start ?end ?members ?article
{
?item wdt:P31 wd:Q5 ; p:P39 ?positionStatement .
?positionStatement ps:P39 ?mpterm . ?mpterm wdt:P279 wd:Q16707842 .
?positionStatement pq:P768 ?constituency .
OPTIONAL { ?constituency wdt:P31 ?type . }
OPTIONAL { ?constituency wdt:P571 ?start . }
OPTIONAL { ?constituency wdt:P576 ?end . }
OPTIONAL { ?constituency wdt:P1410 ?members . }
OPTIONAL { ?article schema:about ?constituency . ?article schema:isPartOf <https://en.wikipedia.org/>. }
# find any where the WP link is on that item
OPTIONAL { ?constituency wdt:P1889 ?different . ?article schema:about ?different . ?article schema:isPartOf <https://en.wikipedia.org/>. }
# find any where the WP link is on a different item (usually the most modern instantiation)
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v9("?article"):::projected
v4("?constituency"):::projected
v10("?different")
v7("?end"):::projected
v1("?item")
v8("?members"):::projected
v3("?mpterm")
v2("?positionStatement")
v6("?start"):::projected
v5("?type")
c6(["wd:Q16707842"]):::iri
c18(["en"]):::literal
c13([https://en.wikipedia.org/]):::iri
c16(["bd:serviceParam"]):::iri
c2(["wd:Q5"]):::iri
v1 --"p:direct/P31"--> c2
v1 --"p:P39"--> v2
v2 --"p:statement/P39"--> v3
v3 --"p:direct/P279"--> c6
v2 --"p:qualifier/P768"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P31".-> v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P571".-> v6
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P576".-> v7
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P1410".-> v8
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v9 -."schema:about".-> v4
v9 --"schema:isPartOf"--> c13
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P1889".-> v10
v9 --"schema:about"--> v10
v9 --"schema:isPartOf"--> c13
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c16 --"wikibase:language"--> c18
end