query-0a8c42ad6ee1f86591092e180ac0933c

rq turtle/ttl

Family tree of the ancestors of Michael Jackson (Q2831). (Q2831)Michael Jackson ) to show the family tree of #defaultView:GraphThe query should use the Graph view (i.e. I've written the following query which I think does what I want

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Graph
SELECT DISTINCT
  ?item
  ?itemLabel
  ?linkTo
{
  { wd:Q2831 wdt:P22* ?item. }
  UNION
  { wd:Q2831 wdt:P25* ?item. }

  OPTIONAL{?item wdt:P22|wdt:P25 ?linkTo}.

  SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE]"}
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?item"):::projected v2("?linkTo"):::projected c5(["bd:serviceParam"]):::iri c7(["#91;AUTO_LANGUAGE#93;"]):::literal c1(["wd:Q2831"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; c1 --"wdt:P25"--> v1 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; c1 --"wdt:P22"--> v1 end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v1 -."wdt:P25".-> v2 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P22"--> v2 end union1r <== or ==> union1l end end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c5 --"wikibase:language"--> c7 end