query-6889fee064bf31ca54d641b3a422f895

rq turtle/ttl

MPs descended from William I SELECT distinct ?mp ?mpLabel ?born ?died WHERE { ?mp p:P39 ?positionStatement . ?positionStatement ps:P39 ?membership . # this person is a member of parliament { ?membership wdt:P279 wd:Q16707842 } # person was a UK MP UNION { ?membership wdt:P279 wd:Q18015642 } # or a British MP (to 1801) UNION { ?membership wdt:P279 wd:Q18018860 } # or an English MP (to 1707) OPTIONAL { ?mp wdt:P569 ?born } . OPTIONAL { ?mp wdt:P570 ?died } . { wd:Q37594 wdt:P40 ?mp . } # person's child, or their child's child, and so on union { ?mp (wdt:P25|wdt:P22)* wd:Q37594 . } # person's parent, or their parent's parent, and so on # # must replace Q37594 in both of the above lines to make this work properly # SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }

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 p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# MPs descended from William I 
SELECT distinct ?mp ?mpLabel ?born ?died WHERE {
  ?mp p:P39 ?positionStatement .
  ?positionStatement ps:P39 ?membership .  # this person is a member of parliament
        { ?membership wdt:P279* wd:Q16707842 }  # person was a UK MP
  UNION { ?membership wdt:P279* wd:Q18015642 }  # or a British MP (to 1801)
  UNION { ?membership wdt:P279* wd:Q18018860 }  # or an English MP (to 1707)
  OPTIONAL { ?mp wdt:P569 ?born } .
  OPTIONAL { ?mp wdt:P570 ?died } .
  {  wd:Q37594 wdt:P40* ?mp . } # person's child, or their child's child, and so on
  union
  { ?mp (wdt:P25|wdt:P22)* wd:Q37594 . } # person's parent, or their parent's parent, and so on
  #
  # must replace Q37594 in both of the above lines to make this work properly
  # 
  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; v4("?born"):::projected v5("?died"):::projected v3("?membership") v1("?mp"):::projected v2("?positionStatement") c6(["wd:Q18018860"]):::iri c4(["wd:Q16707842"]):::iri c16(["en"]):::literal c14(["bd:serviceParam"]):::iri c9(["wd:Q37594"]):::iri c5(["wd:Q18015642"]):::iri v1 --"p:P39"--> v2 v2 --"p:statement/P39"--> v3 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P279"--> c6 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P279"--> c5 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P279"--> c4 end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P569".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P570".-> v5 end 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; v1 --"p:direct/P22"--> c9 end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P25"--> c9 end union3r <== or ==> union3l end end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; c9 --"p:direct/P40"--> v1 end union2r <== or ==> union2l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 end