query-63e3fb926037654f23cd282b998bfbc3
bound), in the hope that this would also reduce processing time. ?y and ?x, where there is no solution with both here (like in the second example UNIONs retrieved by the inner query. Sometimes there is more than one statement for a queried property (e.g. someone has more than one given name), and if this is the case for more than one queried property (e.g. someone has more than one given name and more than one occupation), all combinations of values appear in the resultset (all given names combined with all occupations). I figured this combinatorical problem could be circumvented by using ?personThis is a reduced example; the actual query is much larger, querying more information about the , the query times out: UNIONHowever, when I use
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 schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?person ?personLabel ?givenName ?occupation
WHERE {
{
SELECT ?person
WHERE
{
{
{ ?person wdt:P31/wdt:P279* wd:Q5. }
UNION
{ ?hasSitelink schema:about ?person; schema:isPartOf <https://de.wikipedia.org/>. }
}
?person wdt:P509 wd:Q175111.
}
}
{
{ OPTIONAL { ?person wdt:P735 ?givenNameItem. } }
UNION
{ OPTIONAL { ?person wdt:P106 ?occupationItem. } }
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en". ?person rdfs:label ?personLabel. ?givenNameItem rdfs:label ?givenName. ?occupationItem rdfs:label ?occupation. }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?givenName"):::projected
v3("?givenNameItem")
v2("?hasSitelink")
v7("?occupation"):::projected
v4("?occupationItem")
v1("?person"):::projected
v5("?personLabel"):::projected
a1((" "))
c6([https://de.wikipedia.org/]):::iri
c8(["wd:Q175111"]):::iri
c12(["bd:serviceParam"]):::iri
c3(["wd:Q5"]):::iri
c14(["de,en"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 --"schema:about"--> v1
v2 --"schema:isPartOf"--> c6
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c3
end
union0r <== or ==> union0l
end
v1 --"wdt:P509"--> c8
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P106".-> v4
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P735".-> v3
end
end
union1r <== or ==> union1l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c12 --"wikibase:language"--> c14
v1 --"rdfs:label"--> v5
v3 --"rdfs:label"--> v6
v4 --"rdfs:label"--> v7
end