query-0991740727715a9ffe6516eda7280b01
Graphical version of above, for a different person
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Graph
#title:Objects in collections related to Abdülmecid I
SELECT ?from ?fromLabel ?image1 ?to ?toLabel ?image2 ?edgeLabel
WHERE {
{
SELECT ?from ?image1 (?start AS ?to) (?startimage AS ?image2) (?prop AS ?edge) WHERE {
{
SELECT ?start ?startimage ?image1 ?from ?prop ?coll WHERE {
VALUES ?start {wd:Q174772}. # Choose person to start with
?start wdt:P18 ?startimage.
?from ?rel ?start; wdt:P195 ?coll.
MINUS {?coll wdt:P31 wd:Q61781831} # Exclude curatorial departments
?prop wikibase:directClaim ?rel ; a wikibase:Property.
OPTIONAL {?from wdt:P18 ?image1}.
} }
} ORDER BY ?coll # put objects from the same collection close together
}
UNION {
SELECT ?from ?image1 (?coll AS ?to) ?image2 (wd:P195 AS ?edge) WHERE {
{
SELECT ?start ?startimage ?image1 ?from ?prop ?coll WHERE {
VALUES ?start {wd:Q174772}. # Choose person to start with
?start wdt:P18 ?startimage.
?from ?rel ?start; wdt:P195 ?coll.
MINUS {?coll wdt:P31 wd:Q61781831} # Exclude curatorial departments
?prop wikibase:directClaim ?rel ; a wikibase:Property.
OPTIONAL {?from wdt:P18 ?image1}.
} }
OPTIONAL {?coll wdt:P18 ?image2}.
}
} UNION {
SELECT ?from ?image1 (?type AS ?to) ("" AS ?image2) (wd:P31 AS ?edge) WHERE {
{
SELECT ?start ?startimage ?image1 ?from ?prop ?coll WHERE {
VALUES ?start {wd:Q174772}. # Choose person to start with
?start wdt:P18 ?startimage.
?from ?rel ?start; wdt:P195 ?coll.
MINUS {?coll wdt:P31 wd:Q61781831} # Exclude curatorial departments
?prop wikibase:directClaim ?rel ; a wikibase:Property.
OPTIONAL {?from wdt:P18 ?image1}.
} }
?from wdt:P31 ?type.
}
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?from rdfs:label ?fromLabel. ?edge rdfs:label ?edgeLabel. ?to rdfs:label ?toLabel}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?coll")
v12("?edge")
v13("?edgeLabel"):::projected
v4("?from"):::projected
v12("?fromLabel"):::projected
v7("?image1"):::projected
v12("?image2"):::projected
v6("?prop")
v5("?rel")
v11("?start")
v3("?startimage")
v12("?to"):::projected
v14("?toLabel"):::projected
v11("?type")
c9(["bd:serviceParam"]):::iri
c7(["wikibase:Property"]):::iri
c4(["wd:Q61781831"]):::iri
c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal
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;
bind0[/VALUES ?start/]
bind0-->v11
bind00(["wd:Q174772"])
bind00 --> bind0
v11 --"wdt:P18"--> v3
v4 -->v5--> v11
v4 --"wdt:P195"--> v1
subgraph minus1["MINUS"]
style minus1 stroke-width:6px,fill:pink,stroke:red;
v1 --"wdt:P31"--> c4
end
v6 --"wikibase:directClaim"--> v5
v6 --"a"--> c7
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P18".-> v7
end
v4 --"wdt:P31"--> v11
bind2[/"?type"/]
v11 --o bind2
bind2 --as--o v12
bind3[/"''"/]
bind3 --as--o v12
bind4[/"'wd:P31'"/]
bind4 --as--o v12
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
bind5[/VALUES ?start/]
bind5-->v11
bind50(["wd:Q174772"])
bind50 --> bind5
v11 --"wdt:P18"--> v3
v4 -->v5--> v11
v4 --"wdt:P195"--> v1
subgraph minus6["MINUS"]
style minus6 stroke-width:6px,fill:pink,stroke:red;
v1 --"wdt:P31"--> c4
end
v6 --"wikibase:directClaim"--> v5
v6 --"a"--> c7
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P18".-> v7
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P18".-> v12
end
bind7[/"?coll"/]
v1 --o bind7
bind7 --as--o v12
bind8[/"'wd:P195'"/]
bind8 --as--o v12
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
bind9[/VALUES ?start/]
bind9-->v11
bind90(["wd:Q174772"])
bind90 --> bind9
v11 --"wdt:P18"--> v3
v4 -->v5--> v11
v4 --"wdt:P195"--> v1
subgraph minus10["MINUS"]
style minus10 stroke-width:6px,fill:pink,stroke:red;
v1 --"wdt:P31"--> c4
end
v6 --"wikibase:directClaim"--> v5
v6 --"a"--> c7
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P18".-> v7
end
bind11[/"?start"/]
v11 --o bind11
bind11 --as--o v12
bind12[/"?startimage"/]
v3 --o bind12
bind12 --as--o v12
bind13[/"?prop"/]
v6 --o bind13
bind13 --as--o v12
end
union0r <== or ==> union0l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c9 --"wikibase:language"--> c11
v4 --"rdfs:label"--> v12
v12 --"rdfs:label"--> v13
v12 --"rdfs:label"--> v14
end