query-8cef3310d4037aeb65fc3d1cddd43b63

rq turtle/ttl

Propertiespart of (P361)instance of (P31)subclass of (P279)logo image (P154)inception (P571)dissolved, abolished or demolished date (P576)parent organization (P749)member of (P463)facet of (P1269)country (P17)flag image (P41)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Tree
SELECT
  ?top ?topLabel
  ?parent ?parentLogo (CONCAT(?parentName,' (',COALESCE(STR(YEAR(?parentStart)),'?'),' - ',COALESCE(STR(YEAR(?parentEnd)),'x'),')') AS ?parentLabel)
  ?society ?societyFlag (CONCAT(?societyName,' (',COALESCE(STR(YEAR(?societyStart)),'?'),' - ',COALESCE(STR(YEAR(?societyEnd)),'x'),')') AS ?societyLabel)
  ?branch ?branchFlag (CONCAT(?branchName,' (',COALESCE(STR(YEAR(?branchStart)),'?'),' - ',COALESCE(STR(YEAR(?branchEnd)),'x'),')') AS ?branchLabel)
WHERE {
  ########## IRCRCM ##########
  BIND(wd:Q7178 AS ?top).


  ########## IFRC, ICRC ##########
  ?parent wdt:P361 ?top;
          (wdt:P31/(wdt:P279*)) wd:Q43229.
  OPTIONAL { ?parent wdt:P154 ?parentLogo. }
  OPTIONAL { ?parent wdt:P571 ?parentStart. }
  OPTIONAL { ?parent wdt:P576 ?parentEnd. }


  ########## National societies ##########
  OPTIONAL {
    ?society (wdt:P749|wdt:P463|wdt:P361|wdt:P1269) ?parent;
             (wdt:P31/(wdt:P279*)) wd:Q43229.
    OPTIONAL { ?society wdt:P17/wdt:P41 ?societyFlag. }
    OPTIONAL { ?society wdt:P571 ?societyStart. }
    OPTIONAL { ?society wdt:P576 ?societyEnd. }


    ########## Regional societies and branches ##########
    OPTIONAL {
      ?branch (wdt:P749|wdt:P463|wdt:P361|wdt:P1269) ?society;
              (wdt:P31/(wdt:P279*)) wd:Q43229.
      OPTIONAL { ?branch wdt:P17/wdt:P41 ?branchFlag. }
      OPTIONAL { ?branch wdt:P571 ?branchStart. }
      OPTIONAL { ?branch wdt:P576 ?branchEnd. }
    }
  }

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,sl".
    ?top rdfs:label ?topLabel .
    ?parent rdfs:label ?parentName .
    ?society rdfs:label ?societyName .
    ?branch rdfs:label ?branchName .
  }
}
ORDER BY (?parentLabel) (?societyLabel) (?branchLabel)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v13("?branch"):::projected v16("?branchEnd"):::projected v14("?branchFlag"):::projected v21("?branchLabel") v20("?branchName"):::projected v15("?branchStart"):::projected v5("?parent"):::projected v8("?parentEnd"):::projected v21("?parentLabel") v6("?parentLogo"):::projected v18("?parentName"):::projected v7("?parentStart"):::projected v9("?society"):::projected v12("?societyEnd"):::projected v10("?societyFlag"):::projected v21("?societyLabel") v19("?societyName"):::projected v11("?societyStart"):::projected v4("?top"):::projected v17("?topLabel"):::projected a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) c16(["#91;AUTO_LANGUAGE#93;,en,de,sl"]):::literal c4(["wd:Q43229"]):::iri c14(["bd:serviceParam"]):::iri bind0[/"'wd:Q7178'"/] bind0 --as--o v4 v5 --"wdt:P361"--> v4 v5 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P154".-> v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P571".-> v7 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P576".-> v8 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; 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; v9 -."wdt:P1269".-> v5 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v9 --"wdt:P361"--> v5 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v9 --"wdt:P463"--> v5 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v9 --"wdt:P749"--> v5 end union0r <== or ==> union0l end v9 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c4 subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v9 -."wdt:P17".-> a3 a3 --"wdt:P41"--> v10 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v9 -."wdt:P571".-> v11 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v9 -."wdt:P576".-> v12 end subgraph optional7["(optional)"] style optional7 fill:#bbf,stroke-dasharray: 5 5; 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; v13 -."wdt:P1269".-> v9 end subgraph union5r[" "] style union5r fill:#abf,stroke-dasharray: 3 3; v13 --"wdt:P361"--> v9 end union5r <== or ==> union5l end end subgraph union4r[" "] style union4r fill:#abf,stroke-dasharray: 3 3; v13 --"wdt:P463"--> v9 end union4r <== or ==> union4l end end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; v13 --"wdt:P749"--> v9 end union3r <== or ==> union3l end v13 --"wdt:P31"--> a4 a4 --"wdt:P279"--> c4 subgraph optional8["(optional)"] style optional8 fill:#bbf,stroke-dasharray: 5 5; v13 -."wdt:P17".-> a5 a5 --"wdt:P41"--> v14 end subgraph optional9["(optional)"] style optional9 fill:#bbf,stroke-dasharray: 5 5; v13 -."wdt:P571".-> v15 end subgraph optional10["(optional)"] style optional10 fill:#bbf,stroke-dasharray: 5 5; v13 -."wdt:P576".-> v16 end end end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 v4 --"rdfs:label"--> v17 v5 --"rdfs:label"--> v18 v9 --"rdfs:label"--> v19 v13 --"rdfs:label"--> v20 end bind1[/"concat(?parentName,' (',str(year-from-dateTime(?parentStart))'?',' - ',str(year-from-dateTime(?parentEnd))'x',')')"/] v18 --o bind1 v7 --o bind1 v8 --o bind1 bind1 --as--o v21 bind2[/"concat(?societyName,' (',str(year-from-dateTime(?societyStart))'?',' - ',str(year-from-dateTime(?societyEnd))'x',')')"/] v19 --o bind2 v11 --o bind2 v12 --o bind2 bind2 --as--o v21 bind3[/"concat(?branchName,' (',str(year-from-dateTime(?branchStart))'?',' - ',str(year-from-dateTime(?branchEnd))'x',')')"/] v20 --o bind3 v15 --o bind3 v16 --o bind3 bind3 --as--o v21