query-64f2b87aec1ea3b6ed907e9905f0fd8d
: (Q60)New York City statements) the tree becomes big, but still understandable and fetched in reasonable time, see for example (P31)instance of For entities with multiple classes (multiple
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 bd: <http://www.bigdata.com/rdf#>
#defaultView:Graph
SELECT ?superClass ?rgb ?parent ?superClassLabel ?parentLabel
WHERE {
{
bind ('FF0000' as ?rgb).
bind (wd:Q60 as ?superClass).
?superClass wdt:P31 ?parent.
} UNION {
bind ('FFFFFF' as ?rgb).
wd:Q60 wdt:P31 ?class.
?class wdt:P279* ?superClass.
?superClass wdt:P279 ?parent.
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "it,en,[AUTO_LANGUAGE],en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?class")
v3("?parent"):::projected
v4("?rgb"):::projected
v2("?superClass"):::projected
c5(["bd:serviceParam"]):::iri
c2(["wd:Q60"]):::iri
c7(["it,en,#91;AUTO_LANGUAGE#93;,en"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
bind0[/"'FFFFFF'"/]
bind0 --as--o v4
c2 --"wdt:P31"--> v4
v4 --"wdt:P279"--> v2
v2 --"wdt:P279"--> v3
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
bind1[/"'FF0000'"/]
bind1 --as--o v4
bind2[/"'wd:Q60'"/]
bind2 --as--o v2
v2 --"wdt:P31"--> v3
end
union0r <== or ==> union0l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c7
end