query-036c502bd1970be8eaf228d426489f61

rq turtle/ttl

Political ancestry - MPs with nine direct ancestors who were also MPs, with no breaksNote that this query is computationally very intensive, and may sometimes time out. I am working on refining it.at this linkThis query is too long for the SPARQL template, but can be found Sitting MPs descended from people who were in the UCL Legacy of British Slaveowners database

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
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 ?c ?cLabel ?pLabel ?sLabel ?item ?itemLabel ?lbs
where 
{ 
  { select distinct ?item ?lbs ?c where { ?item wdt:P3023 ?lbs . ?item wdt:P40+ ?c . } }
  { select distinct ?c ?p ?s where 
                       { ?c p:P39 ?ps . ?ps ps:P39 ?pos . ?pos wdt:P279 wd:Q16707842 . ?ps pq:P4100 ?p . ?ps pq:P768 ?s .
                         filter not exists { ?ps pq:P582 ?e } } }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by ?cLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?c"):::projected v1("?cLabel"):::projected v6("?e") v2("?item"):::projected v3("?lbs"):::projected v8("?p") v7("?pos") v5("?ps") v9("?s") c7(["wd:Q16707842"]):::iri c11(["bd:serviceParam"]):::iri c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal v2 --"p:direct/P3023"--> v3 v2 --"p:direct/P40"--> v4 f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0v2 e0v2("?e"):::projected e0v1("?ps"):::projected end f0--EXISTS--> f0e0 f0 --> v5 f0 --> c3 f0 --> v6 v5 --"p:qualifier/P582"--> v6 v4 --"p:P39"--> v5 v5 --"p:statement/P39"--> v7 v7 --"p:direct/P279"--> c7 v5 --"p:qualifier/P4100"--> v8 v5 --"p:qualifier/P768"--> v9 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end