query-7d792697f1e0cea81b0361547fc8aedc

rq turtle/ttl

All archives, museums, libraries and heritage institutions in Switzerland and Fürstentum Liechtenstein

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
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#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item
       ?glamID
       ?Label_en
       ?Description_en
       (group_concat(distinct ?Alias_en;separator="; ") as ?Aliases_en)    #Concatenate the values in order not to get several rows per item.
       ?Label_de
       ?Description_de
       (group_concat(distinct ?Alias_de;separator="; ") as ?Aliases_de)
       (replace(group_concat(distinct ?Type;separator="; "), "http://www.wikidata.org/entity/", "") as ?Types)  #Strip the path in order to get only the Q-number.
       (group_concat(distinct ?TypeLabel_en;separator="; ") as ?TypeLabels_en)
       (replace(group_concat(distinct ?Municipality;separator="; "), "http://www.wikidata.org/entity/", "") as ?Municipalities)   
       (group_concat(distinct ?MunicipalityLabel_de;separator="; ") as ?MunicipalityLabels_de)
       (replace(group_concat(distinct ?Canton;separator="; "), "http://www.wikidata.org/entity/", "") as ?Cantons)
       (group_concat(distinct ?CantonLabel_de;separator="; ") as ?CantonLabels_de)
  WHERE {
  {?item wdt:P31 ?museum . ?museum wdt:P279* wd:Q33506 } 
    UNION {?item wdt:P31 ?archive . ?archive wdt:P279* wd:Q166118 } 
    UNION {?item wdt:P31 ?library . ?library wdt:P279* wd:Q7075 } 
    UNION {?item wdt:P31 ?memory . ?memory wdt:P279* wd:Q1497649 } . 
  {?item wdt:P131/wdt:P17 wd:Q39 }
    UNION {?item wdt:P131/wdt:P17 wd:Q347 } .  
  OPTIONAL { ?item wdt:P3066 ?glamID. }
  OPTIONAL { ?item rdfs:label ?Label_en . FILTER (lang(?Label_en) = "en") }
  OPTIONAL { ?item rdfs:label ?Label_de . FILTER (lang(?Label_de) = "de") } 
  OPTIONAL { ?item skos:altLabel ?Alias_en . FILTER (lang(?Alias_en) = "en") }
  OPTIONAL { ?item skos:altLabel ?Alias_de . FILTER (lang(?Alias_de) = "de") } 
  OPTIONAL { ?item schema:description ?Description_en . FILTER (lang(?Description_en) = "en") }
  OPTIONAL { ?item schema:description ?Description_de . FILTER (lang(?Description_de) = "de") } 
  OPTIONAL { ?item wdt:P31 ?Type. }
  OPTIONAL { ?item wdt:P31/rdfs:label ?TypeLabel_en . FILTER (lang(?TypeLabel_en) = "en") }  
  OPTIONAL { ?item wdt:P131 ?Municipality . FILTER EXISTS {?Municipality wdt:P31 wd:Q70208} }  
  OPTIONAL { ?item wdt:P131/rdfs:label ?MunicipalityLabel_de . FILTER EXISTS {?MunicipalityLabel_de ^rdfs:label/wdt:P31 wd:Q70208} . FILTER (lang(?MunicipalityLabel_de) = "de") }
  OPTIONAL { ?item wdt:P131 ?Canton . FILTER EXISTS {?Canton wdt:P31 wd:Q23058} }
  OPTIONAL { ?item wdt:P131/rdfs:label ?CantonLabel_de . FILTER EXISTS {?CantonLabel_de ^rdfs:label/wdt:P31 wd:Q23058} . FILTER (lang(?CantonLabel_de) = "de") }  
  OPTIONAL { ?item wdt:P17 ?Country. }
  OPTIONAL { ?item wdt:P17/rdfs:label ?CountryLabel_de . FILTER (lang(?CountryLabel_de) = "de") }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }    
}
group by ?item                          #List all the variables for which the values are not concatenated!
         ?glamID
         ?Label_en ?Description_en 
         ?Label_de ?Description_de

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?Alias_de"):::projected v10("?Alias_en"):::projected v25("?Aliases_de") v24("?Aliases_en") v3("?Canton") v2("?CantonLabel_de"):::projected v31("?CantonLabels_de") v30("?Cantons") v20("?Country") v1("?CountryLabel_de") v7("?Description_de"):::projected v8("?Description_en"):::projected v11("?Label_de"):::projected v12("?Label_en"):::projected v28("?Municipalities") v5("?Municipality") v4("?MunicipalityLabel_de"):::projected v29("?MunicipalityLabels_de") v19("?Type") v6("?TypeLabel_en"):::projected v27("?TypeLabels_en") v26("?Types") v21("?_anon_d00291b7e9a143df8ec0be8c8ebd714c70757"):::projected v22("?_anon_d00291b7e9a143df8ec0be8c8ebd714c70758"):::projected v23("?_anon_d00291b7e9a143df8ec0be8c8ebd714c70759"):::projected v15("?archive") v18("?glamID"):::projected v13("?item"):::projected v16("?library") v17("?memory") v14("?museum") a3((" ")) a4((" ")) a5((" ")) a6((" ")) a2((" ")) a7((" ")) a1((" ")) a8((" ")) c1(["de"]):::literal c4(["wd:Q23058"]):::iri c8(["wd:Q33506"]):::iri c11(["wd:Q1497649"]):::iri c14(["wd:Q39"]):::iri c15(["wd:Q347"]):::iri c10(["wd:Q7075"]):::iri c9(["wd:Q166118"]):::iri c20(["bd:serviceParam"]):::iri c5(["wd:Q70208"]):::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; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; v13 --"wdt:P31"--> v17 v17 --"wdt:P279"--> c11 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v13 --"wdt:P31"--> v16 v16 --"wdt:P279"--> c10 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v13 --"wdt:P31"--> v15 v15 --"wdt:P279"--> c9 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v13 --"wdt:P31"--> v14 v14 --"wdt:P279"--> c8 end union0r <== or ==> union0l end subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; v13 --"wdt:P131"--> a4 a4 --"wdt:P17"--> c15 end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; v13 --"wdt:P131"--> a3 a3 --"wdt:P17"--> c14 end union3r <== or ==> union3l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v13 -."wdt:P3066".-> v18 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v13 -."rdfs:label".-> v12 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v13 -."rdfs:label".-> v11 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v13 -."skos:altLabel".-> v10 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v13 -."skos:altLabel".-> v9 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v13 -."schema:description".-> v8 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v13 -."schema:description".-> v7 end subgraph optional7["(optional)"] style optional7 fill:#bbf,stroke-dasharray: 5 5; v13 -."wdt:P31".-> v19 end subgraph optional8["(optional)"] style optional8 fill:#bbf,stroke-dasharray: 5 5; v13 -."wdt:P31".-> a5 a5 --"rdfs:label"--> v6 end subgraph optional9["(optional)"] style optional9 fill:#bbf,stroke-dasharray: 5 5; v13 -."wdt:P131".-> v5 end subgraph optional10["(optional)"] style optional10 fill:#bbf,stroke-dasharray: 5 5; v13 -."wdt:P131".-> a6 a6 --"rdfs:label"--> v4 end subgraph optional11["(optional)"] style optional11 fill:#bbf,stroke-dasharray: 5 5; v13 -."wdt:P131".-> v3 end subgraph optional12["(optional)"] style optional12 fill:#bbf,stroke-dasharray: 5 5; v13 -."wdt:P131".-> a7 a7 --"rdfs:label"--> v2 end subgraph optional13["(optional)"] style optional13 fill:#bbf,stroke-dasharray: 5 5; v13 -."wdt:P17".-> v20 end subgraph optional14["(optional)"] style optional14 fill:#bbf,stroke-dasharray: 5 5; v13 -."wdt:P17".-> a8 a8 --"rdfs:label"--> v1 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c20 --"wikibase:language"--> c1 end bind8[/"?Type"/] v19 --o bind8 bind8 --as--o v21 bind9[/"?Municipality"/] v5 --o bind9 bind9 --as--o v22 bind10[/"?Canton"/] v3 --o bind10 bind10 --as--o v23 bind11[/"?Alias_en"/] v10 --o bind11 bind11 --as--o v24 bind12[/"?Alias_de"/] v9 --o bind12 bind12 --as--o v25 bind13[/"replace(,'http://www.wikidata.org/entity/','')"/] null --o bind13 bind13 --as--o v26 bind14[/"?TypeLabel_en"/] v6 --o bind14 bind14 --as--o v27 bind15[/"replace(,'http://www.wikidata.org/entity/','')"/] null --o bind15 bind15 --as--o v28 bind16[/"?MunicipalityLabel_de"/] v4 --o bind16 bind16 --as--o v29 bind17[/"replace(,'http://www.wikidata.org/entity/','')"/] null --o bind17 bind17 --as--o v30 bind18[/"?CantonLabel_de"/] v2 --o bind18 bind18 --as--o v31