query-14661faf8f3ddd268dffdc207acfdde3

rq turtle/ttl

Ensure electoral district (P768) exists while position held (P39) is valid:(P576)dissolved, abolished or demolished date and (P571)inception 's (P768)electoral district qualifiers are not between their (P582)end time and (P580)start time 's (P39)position held where their (Q654291)Teachta Dála Get all

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 ?item ?itemLabel ?term ?termLabel ?constituency ?constituencyLabel (YEAR(?start) AS ?yearStart) (YEAR(?start1) AS ?yearStart1) (YEAR(?end) AS ?yearEnd) (YEAR(?end1) AS ?yearEnd1) WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item p:P39 ?deputy.
  ?deputy ps:P39 wd:Q654291.
  ?deputy pq:P2937 ?term.
  ?deputy pq:P768 ?constituency.
  ?deputy pq:P580 ?start.
  ?deputy pq:P582 ?end.
  ?constituency wdt:P571 ?start1.
  ?constituency wdt:P576 ?end1.

  FILTER((YEAR(?start)) < (YEAR(?start1)))
  FILTER((YEAR(?end)) > (YEAR(?end1)))
  FILTER((YEAR(?start)) > (YEAR(?end1)))
  FILTER((YEAR(?end)) < (YEAR(?start1)))
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?constituency"):::projected v6("?deputy") v1("?end"):::projected v4("?end1"):::projected v5("?item"):::projected v3("?start"):::projected v2("?start1"):::projected v7("?term"):::projected v11("?yearEnd") v12("?yearEnd1") v9("?yearStart") v10("?yearStart1") c2(["bd:serviceParam"]):::iri c4(["#91;AUTO_LANGUAGE#93;,en"]):::literal c7(["wd:Q654291"]):::iri f0[["year-from-dateTime(?end) < year-from-dateTime(?start1)"]] f0 --> v1 f0 --> v2 f1[["year-from-dateTime(?start) > year-from-dateTime(?end1)"]] f1 --> v3 f1 --> v4 f2[["year-from-dateTime(?end) > year-from-dateTime(?end1)"]] f2 --> v1 f2 --> v4 f3[["year-from-dateTime(?start) < year-from-dateTime(?start1)"]] f3 --> v3 f3 --> v2 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c2 --"wikibase:language"--> c4 end v5 --"p:P39"--> v6 v6 --"p:statement/P39"--> c7 v6 --"p:qualifier/P2937"--> v7 v6 --"p:qualifier/P768"--> v8 v6 --"p:qualifier/P580"--> v3 v6 --"p:qualifier/P582"--> v1 v8 --"p:direct/P571"--> v2 v8 --"p:direct/P576"--> v4 bind4[/"year-from-dateTime(?start)"/] v3 --o bind4 bind4 --as--o v9 bind5[/"year-from-dateTime(?start1)"/] v2 --o bind5 bind5 --as--o v10 bind6[/"year-from-dateTime(?end)"/] v1 --o bind6 bind6 --as--o v11 bind7[/"year-from-dateTime(?end1)"/] v4 --o bind7 bind7 --as--o v12