query-39ddc2adbf98946edb527fc90c3267d3

rq turtle/ttl

Venn of properties by usage scope

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/>
SELECT ?type ?cnt WHERE {
  {
    BIND("main" AS ?type)
    {
      SELECT (COUNT(DISTINCT ?prop) as ?cnt) WHERE {
        ?prop wdt:P2302 wd:Q53869507 .
        ?prop p:P2302 [ps:P2302 wd:Q53869507 ; pq:P5314 wd:Q54828448] .
      }
    }
  } UNION {
    BIND("qual" AS ?type)
    {
      SELECT (COUNT(DISTINCT ?prop) as ?cnt) WHERE {
        ?prop wdt:P2302 wd:Q53869507 .
        ?prop p:P2302 [ps:P2302 wd:Q53869507 ; pq:P5314 wd:Q54828449] .
      }
    }
  } UNION {
    BIND("ref" AS ?type)
    {
      SELECT (COUNT(DISTINCT ?prop) as ?cnt) WHERE {
        ?prop wdt:P2302 wd:Q53869507 .
        ?prop p:P2302 [ps:P2302 wd:Q53869507 ; pq:P5314 wd:Q54828450] .
      }
    }
  } UNION {
    BIND("main qual" AS ?type)
    {
      SELECT (COUNT(DISTINCT ?prop) as ?cnt) WHERE {
        ?prop wdt:P2302 wd:Q53869507 .
        ?prop p:P2302 [ps:P2302 wd:Q53869507 ; pq:P5314 wd:Q54828448 ; pq:P5314 wd:Q54828449] .
      }
    }
  } UNION {
    BIND("main ref" AS ?type)
    {
      SELECT (COUNT(DISTINCT ?prop) as ?cnt) WHERE {
        ?prop wdt:P2302 wd:Q53869507 .
        ?prop p:P2302 [ps:P2302 wd:Q53869507 ; pq:P5314 wd:Q54828448 ; pq:P5314 wd:Q54828450] .
      }
    }
  } UNION {
    BIND("qual ref" AS ?type)
    {
      SELECT (COUNT(DISTINCT ?prop) as ?cnt) WHERE {
        ?prop wdt:P2302 wd:Q53869507 .
        ?prop p:P2302 [ps:P2302 wd:Q53869507 ; pq:P5314 wd:Q54828449 ; pq:P5314 wd:Q54828450] .
      }
    }
  } UNION {
    BIND("main qual ref" AS ?type)
    {
      SELECT (COUNT(DISTINCT ?prop) as ?cnt) WHERE {
        ?prop wdt:P2302 wd:Q53869507 .
        ?prop p:P2302 [ps:P2302 wd:Q53869507 ; pq:P5314 wd:Q54828448 ; pq:P5314 wd:Q54828449 ; pq:P5314 wd:Q54828450] .
      }
    }
  } UNION {
    BIND("none" AS ?type)
    {
      SELECT (COUNT(DISTINCT ?prop) as ?cnt) WHERE {
        ?prop wdt:P2302 wd:Q53869507 .
        FILTER NOT EXISTS {VALUES ?types {wd:Q54828448 wd:Q54828449 wd:Q54828450} ?prop p:P2302 [ps:P2302 wd:Q53869507 ; pq:P5314 ?types] } .
      }
    }
  } UNION {
    BIND("garbage" AS ?type)
    {
      SELECT (COUNT(DISTINCT ?prop) as ?cnt) WHERE {
        ?prop wdt:P2302 wd:Q53869507 .
        FILTER EXISTS {?prop p:P2302 [ps:P2302 wd:Q53869507 ; pq:P5314 ?x] FILTER(?x != wd:Q54828448 && ?x != wd:Q54828449 && ?x != wd:Q54828450) } .
      }
    }
  } UNION {
    BIND("not set" AS ?type)
    {
      SELECT (COUNT(DISTINCT ?prop) as ?cnt) WHERE {
        ?prop a wikibase:Property .
        FILTER NOT EXISTS {?prop wdt:P2302 wd:Q53869507} .
      }
    }
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?cnt"):::projected v2("?prop") v6("?type"):::projected v4("?types") v5("?x") a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) a6((" ")) a7((" ")) a8((" ")) a9((" ")) c8(["wd:Q54828450"]):::iri c10(["wikibase:Property"]):::iri c2(["wd:Q53869507"]):::iri c5(["wd:Q54828448"]):::iri c7(["wd:Q54828449"]):::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; subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; subgraph union4[" Union "] subgraph union4l[" "] style union4l fill:#abf,stroke-dasharray: 3 3; subgraph union5[" Union "] subgraph union5l[" "] style union5l fill:#abf,stroke-dasharray: 3 3; subgraph union6[" Union "] subgraph union6l[" "] style union6l fill:#abf,stroke-dasharray: 3 3; subgraph union7[" Union "] subgraph union7l[" "] style union7l fill:#abf,stroke-dasharray: 3 3; subgraph union8[" Union "] subgraph union8l[" "] style union8l fill:#abf,stroke-dasharray: 3 3; bind0[/"'not set'"/] bind0 --as--o v6 f1[["not "]] subgraph f1e0["Exists Clause"] e0v1 --"p:direct/P2302"--> e0c2 e0v1("?prop"):::projected e0c2(["wd:Q53869507"]):::iri end f1--EXISTS--> f1e0 f1 --> v2 f1 --> c1 f1 --> c2 v2 --"p:direct/P2302"--> c2 v2 --"a"--> c10 bind3[/"count(?prop)"/] v2 --o bind3 bind3 --as--o v6 end subgraph union8r[" "] style union8r fill:#abf,stroke-dasharray: 3 3; bind4[/"'garbage'"/] bind4 --as--o v6 f5[[" "]] subgraph f5e1["Exists Clause"] e1f0[["?x != 'wd:Q54828448'?x != 'wd:Q54828449'?x != 'wd:Q54828450'"]] e1f0 --> e1v1 e1a1 --"p:statement/P2302"--> e1c5 e1a1 --"p:qualifier/P5314"--> e1v1 e1v2 --"p:P2302"--> e1a1 e1v2("?prop"):::projected e1v1("?x"):::projected e1a1((" ")):::projected e1c5(["wd:Q53869507"]):::iri end f5--EXISTS--> f5e1 f5 --> v5 f5 --> a9 f5 --> c3 f5 --> c2 f5 --> c4 f5 --> v2 f5 --> c6 f6[["?x != 'wd:Q54828448'?x != 'wd:Q54828449'?x != 'wd:Q54828450'"]] f6 --> v5 a9 --"p:statement/P2302"--> c2 a9 --"p:qualifier/P5314"--> v5 v2 --"p:P2302"--> a9 v2 --"p:direct/P2302"--> c2 bind8[/"count(?prop)"/] v2 --o bind8 bind8 --as--o v6 end union8r <== or ==> union8l end end subgraph union7r[" "] style union7r fill:#abf,stroke-dasharray: 3 3; bind9[/"'none'"/] bind9 --as--o v6 f10[["not "]] subgraph f10e2["Exists Clause"] bind0[/VALUES ?types/] bind0-->e2v1 bind00(["wd:Q54828448"]) bind00 --> bind0 bind01(["wd:Q54828449"]) bind01 --> bind0 bind02(["wd:Q54828450"]) bind02 --> bind0 e2a1 --"p:statement/P2302"--> e2c2 e2a1 --"p:qualifier/P5314"--> e2v1 e2v2 --"p:P2302"--> e2a1 e2v2("?prop"):::projected e2v1("?types"):::projected e2a1((" ")):::projected e2c2(["wd:Q53869507"]):::iri end f10--EXISTS--> f10e2 f10 --> a8 f10 --> c3 f10 --> c2 f10 --> c4 f10 --> v4 f10 --> v2 f10 --> c6 bind11[/VALUES ?types/] bind11-->v4 bind110(["wd:Q54828448"]) bind110 --> bind11 bind111(["wd:Q54828449"]) bind111 --> bind11 bind112(["wd:Q54828450"]) bind112 --> bind11 a8 --"p:statement/P2302"--> c2 a8 --"p:qualifier/P5314"--> v4 v2 --"p:P2302"--> a8 v2 --"p:direct/P2302"--> c2 bind13[/"count(?prop)"/] v2 --o bind13 bind13 --as--o v6 end union7r <== or ==> union7l end end subgraph union6r[" "] style union6r fill:#abf,stroke-dasharray: 3 3; bind14[/"'main qual ref'"/] bind14 --as--o v6 v2 --"p:direct/P2302"--> c2 a7 --"p:statement/P2302"--> c2 a7 --"p:qualifier/P5314"--> c5 a7 --"p:qualifier/P5314"--> c7 a7 --"p:qualifier/P5314"--> c8 v2 --"p:P2302"--> a7 bind16[/"count(?prop)"/] v2 --o bind16 bind16 --as--o v6 end union6r <== or ==> union6l end end subgraph union5r[" "] style union5r fill:#abf,stroke-dasharray: 3 3; bind17[/"'qual ref'"/] bind17 --as--o v6 v2 --"p:direct/P2302"--> c2 a6 --"p:statement/P2302"--> c2 a6 --"p:qualifier/P5314"--> c7 a6 --"p:qualifier/P5314"--> c8 v2 --"p:P2302"--> a6 bind19[/"count(?prop)"/] v2 --o bind19 bind19 --as--o v6 end union5r <== or ==> union5l end end subgraph union4r[" "] style union4r fill:#abf,stroke-dasharray: 3 3; bind20[/"'main ref'"/] bind20 --as--o v6 v2 --"p:direct/P2302"--> c2 a5 --"p:statement/P2302"--> c2 a5 --"p:qualifier/P5314"--> c5 a5 --"p:qualifier/P5314"--> c8 v2 --"p:P2302"--> a5 bind22[/"count(?prop)"/] v2 --o bind22 bind22 --as--o v6 end union4r <== or ==> union4l end end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; bind23[/"'main qual'"/] bind23 --as--o v6 v2 --"p:direct/P2302"--> c2 a4 --"p:statement/P2302"--> c2 a4 --"p:qualifier/P5314"--> c5 a4 --"p:qualifier/P5314"--> c7 v2 --"p:P2302"--> a4 bind25[/"count(?prop)"/] v2 --o bind25 bind25 --as--o v6 end union3r <== or ==> union3l end end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; bind26[/"'ref'"/] bind26 --as--o v6 v2 --"p:direct/P2302"--> c2 a3 --"p:statement/P2302"--> c2 a3 --"p:qualifier/P5314"--> c8 v2 --"p:P2302"--> a3 bind28[/"count(?prop)"/] v2 --o bind28 bind28 --as--o v6 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; bind29[/"'qual'"/] bind29 --as--o v6 v2 --"p:direct/P2302"--> c2 a2 --"p:statement/P2302"--> c2 a2 --"p:qualifier/P5314"--> c7 v2 --"p:P2302"--> a2 bind31[/"count(?prop)"/] v2 --o bind31 bind31 --as--o v6 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; bind32[/"'main'"/] bind32 --as--o v6 v2 --"p:direct/P2302"--> c2 a1 --"p:statement/P2302"--> c2 a1 --"p:qualifier/P5314"--> c5 v2 --"p:P2302"--> a1 bind34[/"count(?prop)"/] v2 --o bind34 bind34 --as--o v6 end union0r <== or ==> union0l end