query-4dd752c499b320d97be57b8bf57aeefb

rq turtle/ttl

Properties: (Q747074)commune of Italy The following properties should be used for a proper and common characterization of a )(Q2824645)administrative territorial entity of Italy (or of an instance of a (Q15089)province of Italy of (P131)located in the administrative territorial entity (P2046)area (P625)coordinate location (Q954172)sparse municipality of (P31)instance of OR (Q747074)commune of Italy of (P31)instance of or to an instance of an its subclass, there could be a case where it could belong to an upper level administrative entity. (Q15089)province of Italy normally belongs to a (Q747074)commune of Italy , do not use both else queries could report the item twice. Although a (Q747074)commune of Italy is a subclass of (Q954172)sparse municipality Please note that

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Italia: regions, provinces and comuni
#defaultView:Tree
SELECT ?regione ?regioneLabel ?provincia ?provinciaLabel ?comune ?comuneLabel
WHERE 
{
  ?regione p:P31/ps:P31/wdt:P279* wd:Q16110 .    # Regions of Italia
  ?provincia wdt:P131 ?regione .                 # Administrative divisions in the region

  { ?provincia wdt:P31 wd:Q15089 . }             # List of provinces
  UNION
  { ?provincia wdt:P31 wd:Q15110 . }             # metropolitan cities of Italy
  UNION
  { ?provincia wdt:P31 wd:Q21190155 . }          # Liberi consorzi comunali of Sicily

  ?comune wdt:P131 ?provincia .                  # Administrative divisions in the province
  {
    ?comune wdt:P31 wd:Q747074 .                 # Italian municipality
  }
  UNION
  {
    ?comune wdt:P31 wd:Q954172 .                 # Italian sparse municipality
  } 

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?comune"):::projected v2("?provincia"):::projected v1("?regione"):::projected a1((" ")) a2((" ")) c11(["wd:Q954172"]):::iri c9(["wd:Q21190155"]):::iri c13(["bd:serviceParam"]):::iri c4(["wd:Q16110"]):::iri c8(["wd:Q15110"]):::iri c15(["#91;AUTO_LANGUAGE#93;,en"]):::literal c7(["wd:Q15089"]):::iri c10(["wd:Q747074"]):::iri v1 --"p:P31"--> a1 a1 --"p:statement/P31"--> a2 a2 --"p:direct/P279"--> c4 v2 --"p:direct/P131"--> v1 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; v2 --"p:direct/P31"--> c9 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P31"--> c8 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P31"--> c7 end union0r <== or ==> union0l end v3 --"p:direct/P131"--> v2 subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P31"--> c11 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P31"--> c10 end union2r <== or ==> union2l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c13 --"wikibase:language"--> c15 end