query-5090c98024f9475bb416ed9e55f4f83a

rq turtle/ttl

Examples of SPARQL QueriesFamily tree of the ancestors of a given person Ancestors of Willem-Alexander of the Netherlands Humans without children

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
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#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Graph
SELECT
  ?item
  ?itemLabel
  ?linkTo
  ?linkToLabel
  (?propertyLabel AS ?edgeLabel)
{
  wd:Q179577 (wdt:P22|wdt:P25)* ?item.

  {?item p:P22 [ps:P22 ?linkTo; ?ps []].}
  UNION
  {?item p:P25 [ps:P25 ?linkTo; ?ps []].}

  ?property wikibase:statementProperty ?ps.

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en".
    ?item rdfs:label ?itemLabel.
    ?linkTo rdfs:label ?linkToLabel.
    ?property rdfs:label ?propertyLabel.
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?edgeLabel") v1("?item"):::projected v5("?itemLabel"):::projected v2("?linkTo"):::projected v6("?linkToLabel"):::projected v4("?property") v7("?propertyLabel"):::projected v3("?ps") a2((" ")) a4((" ")) a1((" ")) a3((" ")) c12(["en"]):::literal c10(["bd:serviceParam"]):::iri c1(["wd:Q179577"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; c1 --"p:direct/P25"--> v1 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; c1 --"p:direct/P22"--> v1 end union0r <== or ==> union0l end subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; a3 --"p:statement/P25"--> v2 a3 -->v3--> a4 v1 --"p:P25"--> a3 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; a1 --"p:statement/P22"--> v2 a1 -->v3--> a2 v1 --"p:P22"--> a1 end union1r <== or ==> union1l end v4 --"wikibase:statementProperty"--> v3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 v1 --"rdfs:label"--> v5 v2 --"rdfs:label"--> v6 v4 --"rdfs:label"--> v7 end bind0[/"?propertyLabel"/] v7 --o bind0 bind0 --as--o v8