query-2f8ab8d488ae3124bd9e2b86457467d5
Exploring the Wikidata Ontology in a Given DomainGet all the subclasses of heritage institutions in several languages: (examples: enter Q7075 for the class "library"; P4646 for the property "representation of")Wikidata Ontology ExplorerUse the Propertiessubclass of (P279) Subclasses of Heritage Institutions
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?item
(group_concat(distinct ?superClassLabel_en;separator="; ") as ?superClassLabels_en) #Concatenate the values in order not to get several rows per item.
(replace(group_concat(distinct ?superClass;separator="; "), "http://www.wikidata.org/entity/", "") as ?superClasses) #Strip the path in order to get only the Q-number.
?Label_en
(group_concat(distinct ?Alias_en;separator="; ") as ?Aliases_en) #Concatenate the values in order not to get several rows per item.
?Label_de
(group_concat(distinct ?Alias_de;separator="; ") as ?Aliases_de)
?Label_fr
(group_concat(distinct ?Alias_fr;separator="; ") as ?Aliases_fr)
?Label_it
(group_concat(distinct ?Alias_it;separator="; ") as ?Aliases_it)
?Label_es
(group_concat(distinct ?Alias_es;separator="; ") as ?Aliases_es)
?Label_ru
(group_concat(distinct ?Alias_ru;separator="; ") as ?Aliases_ru)
?Description_en
?Description_de
?Description_fr
?Description_it
?Description_es
?Description_ru
WHERE {
{?item wdt:P279+ wd:Q33506} UNION {?item wdt:P279+ wd:Q166118} UNION {?item wdt:P279+ wd:Q7075}.
OPTIONAL { ?item rdfs:label ?Label_en . FILTER (lang(?Label_en) = "en") }
OPTIONAL { ?item rdfs:label ?Label_de . FILTER (lang(?Label_de) = "de") }
OPTIONAL { ?item rdfs:label ?Label_fr . FILTER (lang(?Label_fr) = "fr") }
OPTIONAL { ?item rdfs:label ?Label_it . FILTER (lang(?Label_it) = "it") }
OPTIONAL { ?item rdfs:label ?Label_es . FILTER (lang(?Label_es) = "es") }
OPTIONAL { ?item rdfs:label ?Label_ru . FILTER (lang(?Label_ru) = "ru") }
OPTIONAL { ?item skos:altLabel ?Alias_en . FILTER (lang(?Alias_en) = "en") }
OPTIONAL { ?item skos:altLabel ?Alias_de . FILTER (lang(?Alias_de) = "de") }
OPTIONAL { ?item skos:altLabel ?Alias_fr . FILTER (lang(?Alias_fr) = "fr") }
OPTIONAL { ?item skos:altLabel ?Alias_it . FILTER (lang(?Alias_it) = "it") }
OPTIONAL { ?item skos:altLabel ?Alias_es . FILTER (lang(?Alias_es) = "es") }
OPTIONAL { ?item skos:altLabel ?Alias_ru . FILTER (lang(?Alias_ru) = "ru") }
OPTIONAL { ?item schema:description ?Description_en . FILTER (lang(?Description_en) = "en") }
OPTIONAL { ?item schema:description ?Description_de . FILTER (lang(?Description_de) = "de") }
OPTIONAL { ?item schema:description ?Description_fr . FILTER (lang(?Description_fr) = "fr") }
OPTIONAL { ?item schema:description ?Description_it . FILTER (lang(?Description_it) = "it") }
OPTIONAL { ?item schema:description ?Description_es . FILTER (lang(?Description_es) = "es") }
OPTIONAL { ?item schema:description ?Description_ru . FILTER (lang(?Description_ru) = "ru") }
OPTIONAL { ?item wdt:P279 ?superClass }
OPTIONAL { ?item wdt:P279/rdfs:label ?superClassLabel_en . FILTER (lang(?superClassLabel_en) = "en") }
}
group by ?item #List all the variables for which the values are not concatenated!
?Label_en ?Description_en
?Label_de ?Description_de
?Label_fr ?Description_fr
?Label_it ?Description_it
?Label_es ?Description_es
?Label_ru ?Description_ru
Query found at
- https://www.wikidata.org/wiki/User:Beat_Estermann/WD-Atelier_2018
- https://www.wikidata.org/wiki/User:Beat_Estermann/WD-Intro-2019-05-13
- https://www.wikidata.org/wiki/User:Beat_Estermann/WD-Intro-2019-08-21
- https://www.wikidata.org/wiki/User:Beat_Estermann/WD-Intro-2019-09-26
- https://www.wikidata.org/wiki/User:Beat_Estermann/WD-Intro-2020-08-25
- https://www.wikidata.org/wiki/User:Beat_Estermann/WD_Hackdays_2019/Session_1
- https://www.wikidata.org/wiki/User:Beat_Estermann/WD_Intro_Swiss_National_Library_2018
- https://www.wikidata.org/wiki/Wikidata:WikiProject_Cultural_heritage/Reports/Ingesting_Swiss_heritage_institutions
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v12("?Alias_de"):::projected
v13("?Alias_en"):::projected
v9("?Alias_es"):::projected
v11("?Alias_fr"):::projected
v10("?Alias_it"):::projected
v8("?Alias_ru"):::projected
v26("?Aliases_de")
v25("?Aliases_en")
v29("?Aliases_es")
v27("?Aliases_fr")
v28("?Aliases_it")
v30("?Aliases_ru")
v6("?Description_de"):::projected
v7("?Description_en"):::projected
v3("?Description_es"):::projected
v5("?Description_fr"):::projected
v4("?Description_it"):::projected
v2("?Description_ru"):::projected
v18("?Label_de"):::projected
v19("?Label_en"):::projected
v15("?Label_es"):::projected
v17("?Label_fr"):::projected
v16("?Label_it"):::projected
v14("?Label_ru"):::projected
v22("?_anon_42b5416610844a34809f33a099ae9de163345"):::projected
v20("?item"):::projected
v21("?superClass")
v1("?superClassLabel_en"):::projected
v23("?superClassLabels_en")
v24("?superClasses")
a1((" "))
c8(["wd:Q33506"]):::iri
c10(["wd:Q7075"]):::iri
c9(["wd:Q166118"]):::iri
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;
v20 --"wdt:P279"--> c10
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v20 --"wdt:P279"--> c9
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v20 --"wdt:P279"--> c8
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v20 -."rdfs:label".-> v19
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v20 -."rdfs:label".-> v18
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v20 -."rdfs:label".-> v17
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v20 -."rdfs:label".-> v16
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v20 -."rdfs:label".-> v15
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v20 -."rdfs:label".-> v14
end
subgraph optional6["(optional)"]
style optional6 fill:#bbf,stroke-dasharray: 5 5;
v20 -."skos:altLabel".-> v13
end
subgraph optional7["(optional)"]
style optional7 fill:#bbf,stroke-dasharray: 5 5;
v20 -."skos:altLabel".-> v12
end
subgraph optional8["(optional)"]
style optional8 fill:#bbf,stroke-dasharray: 5 5;
v20 -."skos:altLabel".-> v11
end
subgraph optional9["(optional)"]
style optional9 fill:#bbf,stroke-dasharray: 5 5;
v20 -."skos:altLabel".-> v10
end
subgraph optional10["(optional)"]
style optional10 fill:#bbf,stroke-dasharray: 5 5;
v20 -."skos:altLabel".-> v9
end
subgraph optional11["(optional)"]
style optional11 fill:#bbf,stroke-dasharray: 5 5;
v20 -."skos:altLabel".-> v8
end
subgraph optional12["(optional)"]
style optional12 fill:#bbf,stroke-dasharray: 5 5;
v20 -."schema:description".-> v7
end
subgraph optional13["(optional)"]
style optional13 fill:#bbf,stroke-dasharray: 5 5;
v20 -."schema:description".-> v6
end
subgraph optional14["(optional)"]
style optional14 fill:#bbf,stroke-dasharray: 5 5;
v20 -."schema:description".-> v5
end
subgraph optional15["(optional)"]
style optional15 fill:#bbf,stroke-dasharray: 5 5;
v20 -."schema:description".-> v4
end
subgraph optional16["(optional)"]
style optional16 fill:#bbf,stroke-dasharray: 5 5;
v20 -."schema:description".-> v3
end
subgraph optional17["(optional)"]
style optional17 fill:#bbf,stroke-dasharray: 5 5;
v20 -."schema:description".-> v2
end
subgraph optional18["(optional)"]
style optional18 fill:#bbf,stroke-dasharray: 5 5;
v20 -."wdt:P279".-> v21
end
subgraph optional19["(optional)"]
style optional19 fill:#bbf,stroke-dasharray: 5 5;
v20 -."wdt:P279".-> a1
a1 --"rdfs:label"--> v1
end
bind8[/"?superClass"/]
v21 --o bind8
bind8 --as--o v22
bind9[/"?superClassLabel_en"/]
v1 --o bind9
bind9 --as--o v23
bind10[/"replace(,'http://www.wikidata.org/entity/','')"/]
null --o bind10
bind10 --as--o v24
bind11[/"?Alias_en"/]
v13 --o bind11
bind11 --as--o v25
bind12[/"?Alias_de"/]
v12 --o bind12
bind12 --as--o v26
bind13[/"?Alias_fr"/]
v11 --o bind13
bind13 --as--o v27
bind14[/"?Alias_it"/]
v10 --o bind14
bind14 --as--o v28
bind15[/"?Alias_es"/]
v9 --o bind15
bind15 --as--o v29
bind16[/"?Alias_ru"/]
v8 --o bind16
bind16 --as--o v30