query-eb7b41aab16bb4854ffcbacd1e52d48e

rq turtle/ttl

...the same but query optimized to prevent a timeout

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 pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?bundesland ?bundeslandLabel ?stadt ?stadtLabel ?w ?wLabel ?affiliationTypeLabel ?p ?pLabel WHERE {
{
SELECT DISTINCT ?bundesland ?stadt ?w ?affiliationType ?p WHERE {
  {
   ?w wdt:P463 wd:Q105757481 .
  } UNION {
    ?p wdt:P31 wd:Q98270496 .
    ?p p:P1416 ?statement .
    ?statement ps:P1416 ?w .
    OPTIONAL { ?statement pq:P3831 ?affiliationType .}  
  }
  OPTIONAL {
    ?w wdt:P131+ ?stadt .
    {?stadt  wdt:P31/wdt:P279* wd:Q515} UNION {?stadt  wdt:P31/wdt:P279* wd:Q116457956 } 
    OPTIONAL {
      ?stadt wdt:P131* ?bundesland .
      ?bundesland  wdt:P31 wd:Q1221156 .
     }
   }
  OPTIONAL {
    ?w wdt:P159/wdt:P131* ?stadt . 
    ?stadt  wdt:P31/wdt:P279* wd:Q515 . 
    OPTIONAL {
      ?stadt wdt:P131* ?bundesland .
      ?bundesland  wdt:P31 wd:Q1221156 .
     }    
   }
  #FILTER (?bundesland = wd:Q985)
  #FILTER (?stadt = wd:Q3150) 
  FILTER NOT EXISTS {?w  wdt:P31 wd:Q98270496 }  # do nit display consortia associations to Base4NFDI
}
  }
  BIND(IF(! Bound(?affiliationType), "NFDI-Vereinsmitglied", ?affiliationTypeLabel) AS ?affiliationTypeLabel)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en" . }
} ORDER BY ASC(?bundeslandLabel) ASC(?stadtLabel) ASC(?affiliationTypeLabel) ASC(?wLabel)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?affiliationType") v11("?affiliationTypeLabel"):::projected v10("?bundesland"):::projected v1("?bundeslandLabel"):::projected v6("?p"):::projected v9("?stadt"):::projected v2("?stadtLabel"):::projected v7("?statement") v5("?w"):::projected v4("?wLabel"):::projected a1((" ")) a2((" ")) a3((" ")) a4((" ")) c4(["wd:Q105757481"]):::iri c11(["wd:Q116457956"]):::iri c15(["bd:serviceParam"]):::iri c10(["wd:Q515"]):::iri c12(["wd:Q1221156"]):::iri c17(["de,en"]):::literal c2(["wd:Q98270496"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:direct/P31"--> e0c2 e0v1("?w"):::projected e0c2(["wd:Q98270496"]):::iri end f0--EXISTS--> f0e0 f0 --> v5 f0 --> c1 f0 --> c2 v5 --"p:direct/P31"--> c2 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v6 --"p:direct/P31"--> c2 v6 --"p:P1416"--> v7 v7 --"p:statement/P1416"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:qualifier/P3831".-> v8 end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P463"--> c4 end union0r <== or ==> union0l end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P131".-> v9 subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v9 --"p:direct/P31"--> a2 a2 --"p:direct/P279"--> c11 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v9 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c10 end union1r <== or ==> union1l end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v9 -."p:direct/P131".-> v10 v10 --"p:direct/P31"--> c12 end end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P159".-> a3 a3 --"p:direct/P131"--> v9 v9 --"p:direct/P31"--> a4 a4 --"p:direct/P279"--> c10 subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v9 -."p:direct/P131".-> v10 v10 --"p:direct/P31"--> c12 end end bind1[/"if(not bound(?affiliationType),'NFDI-Vereinsmitglied',?affiliationTypeLabel)"/] v8 --o bind1 v11 --o bind1 bind1 --as--o v11 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c15 --"wikibase:language"--> c17 end