query-d4de5632db3671d5deaa513bab5006fb

rq turtle/ttl

10:35, 18 March 2019 (UTC)) talk (BouzinacThanks. pagetalk / TomT0m author : It makes the queries uselessly complicated. There are two ways to express the number is a total number : either no qualifier at all or a « whole » value … I’d prefer a « total number » property for example, this would make the query a lot simpler. That’s why I think it’s a bad design decision … Tagishsimon@ 11:19, 18 March 2019 (UTC)) talk (Tagishsimon --goes off Tomt0m somewhat. or has no applied to qualifier. (Q2165236)everything What's wrong with my applies to pattern, Tom? How would you do it differently? Given Bouzinac's spec, it seemed an effective solution to identify whether the patronage statement applied to It doesn't work because the Patronage statements have no pq:P585 qualifiers. You'd need to make the ?time business optional to get AMM to work. 10:58, 18 March 2019 (UTC) pagetalk / TomT0m author I don’t know but the « applies to : whole » pattern is really horrible /o\ Arguably, a different more readable way to express the same query :

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 ?item ?itemLabel ?year (sample(?number) as ?number) (group_concat(?IATA;separator=" ") as ?IATAs)
WHERE {
  ?item wdt:P238 ?IATA ;
        p:P3872 ?statement        
        VALUES ?IATA {"SIN" }
        .

  ?statement pq:P585 ?time ;
             ps:P3872 ?number 
             filter not exists {
               ?statement pq:P518 ?applies filter (?applies != wd:Q2165236) . # filtering out statements if they applies to a part that is not the whole (should not be necessary in a better model)
             } .
  MINUS { ?statement wikibase:rank wikibase:DeprecatedRank }

  # computing statements who have « applies to part : everywhere »
  optional { 
    ?statement pq:P518 ?applies. 
    bind("everywhere" as ?everywhere)
  }

  bind (YEAR(?time) AS ?year).

  # if everywhere is not bound, there is no applies
  bind(coalesce(?everywhere, "no applies") as ?where)

  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,ro,pt". }
} group by ?year ?item ?itemLabel
order by ?item desc (?year)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?IATA"):::projected v10("?IATAs") v3("?applies") v8("?everywhere") v1("?item"):::projected v10("?number"):::projected v4("?statement") v6("?time") v9("?where") v9("?year"):::projected c10(["bd:serviceParam"]):::iri c8(["wikibase:DeprecatedRank"]):::iri c12(["fr,en,ro,pt"]):::literal f0[["not "]] subgraph f0e0["Exists Clause"] e0f0[["?applies != 'wd:Q2165236'"]] e0f0 --> e0v1 e0v2 --"p:qualifier/P518"--> e0v1 e0v1("?applies"):::projected e0v2("?statement"):::projected end f0--EXISTS--> f0e0 f0 --> v3 f0 --> v4 f0 --> c2 f1[["?applies != 'wd:Q2165236'"]] f1 --> v3 v4 --"p:qualifier/P518"--> v3 v1 --"p:direct/P238"--> v6 v1 --"p:P3872"--> v4 bind2[/VALUES ?IATA/] bind2-->v6 bind20(["SIN"]) bind20 --> bind2 v4 --"p:qualifier/P585"--> v6 v4 --"p:statement/P3872"--> v10 subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; v4 --"wikibase:rank"--> c8 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:qualifier/P518".-> v3 bind4[/"'everywhere'"/] bind4 --as--o v8 end bind5[/"year-from-dateTime(?time)"/] v6 --o bind5 bind5 --as--o v9 bind6[/"?everywhere'no applies'"/] v8 --o bind6 bind6 --as--o v9 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end bind9[/"sample(?number)"/] v10 --o bind9 bind9 --as--o v10 bind10[/"?IATA"/] v6 --o bind10 bind10 --as--o v10