query-64e23723cf7afd230b655caa8f61f995

rq turtle/ttl

this query

- checks every President of France

- finds out who was President on the day they were born

- finds out if that person was still alive on the day the new one became President

this is a deeply trivial query

but as it turns out to be true for Macron, it's an interesting footnote

and we should see if it's true for anyone else

SELECT ?newperson ?newpersonLabel ?newstart ?oldperson ?oldpersonLabel ?died # ?newbirth ?start ?end WHERE {

# first, find all presidents (as ?newperson) with their accession dates and birthdates

?newperson wdt:P31 wd:Q5 ; wdt:P39 wd:Q191954 . # this is hardcoded as President of France ?newperson wdt:P569 ?newbirth . ?newperson p:P39 [ ps:P39 wd:Q191954; pq:P580 ?newstart ].

# then, find all presidents again (as ?oldperson) with their start/finish dates and deathdates

?oldperson wdt:P31 wd:Q5 ; wdt:P39 wd:Q191954 . OPTIONAL { ?oldperson wdt:P570 ?died . } ?oldperson p:P39 [ ps:P39 wd:Q191954; pq:P580 ?start ] . ?oldperson p:P39 [ ps:P39 wd:Q191954; pq:P582 ?end ] . FILTER ( ?start < ?newbirth ) . # when the new person was born, the old person had begun their term FILTER ( ?end > ?newbirth ) . # when the new person was born, the old person had not finished their term # therefore combined, this was presumably the person on the day they were born # can uncomment ?newbirth ?start ?end to check { FILTER ( ?newstart < ?died ) } UNION { FILTER NOT EXISTS{ ?oldperson wdt:P570 ?died } } . # this complete mess of a query finds the cases # a) where the new person's start date is before the old person's death # b) where the old person has not yet died

SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } # get their names }

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#>
# this query
# - checks every President of France
# - finds out who was President on the day they were born
# - finds out if that person was still alive on the day the new one became President
#
# this is a deeply trivial query
# but as it turns out to be true for Macron, it's an interesting footnote
# and we should see if it's true for anyone else

SELECT ?newperson ?newpersonLabel ?newstart ?oldperson ?oldpersonLabel ?died # ?newbirth ?start ?end 
WHERE {

  # first, find all presidents (as ?newperson) with their accession dates and birthdates

  ?newperson wdt:P31 wd:Q5 ; wdt:P39 wd:Q191954 .  # this is hardcoded as President of France
  ?newperson wdt:P569 ?newbirth .
  ?newperson p:P39 [ ps:P39 wd:Q191954; pq:P580 ?newstart ]. 

  # then, find all presidents again (as ?oldperson) with their start/finish dates and deathdates

  ?oldperson wdt:P31 wd:Q5 ; wdt:P39 wd:Q191954 .
  OPTIONAL { ?oldperson wdt:P570 ?died . }
  ?oldperson p:P39 [ ps:P39 wd:Q191954; pq:P580 ?start ] .
  ?oldperson p:P39 [ ps:P39 wd:Q191954; pq:P582 ?end ] .
  FILTER ( ?start < ?newbirth ) .  # when the new person was born, the old person had begun their term
  FILTER ( ?end > ?newbirth ) .    # when the new person was born, the old person had not finished their term
                                   # therefore combined, this was presumably the person on the day they were born
                                   # can uncomment ?newbirth ?start ?end to check
  { FILTER ( ?newstart < ?died ) } UNION { FILTER NOT EXISTS{ ?oldperson wdt:P570 ?died } } .
                                   # this complete mess of a query finds the cases
                                   # a) where the new person's start date is before the old person's death
                                   # b) where the old person has not yet died


  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }  # get their names
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?died"):::projected v1("?end") v2("?newbirth") v4("?newperson"):::projected v5("?newstart"):::projected v6("?oldperson"):::projected v3("?start") a1((" ")) a2((" ")) a3((" ")) c14(["en"]):::literal c4(["wd:Q191954"]):::iri c12(["bd:serviceParam"]):::iri c2(["wd:Q5"]):::iri f0[["?end > ?newbirth"]] f0 --> v1 f0 --> v2 f1[["?start < ?newbirth"]] f1 --> v3 f1 --> v2 v4 --"p:direct/P31"--> c2 v4 --"p:direct/P39"--> c4 v4 --"p:direct/P569"--> v2 a1 --"p:statement/P39"--> c4 a1 --"p:qualifier/P580"--> v5 v4 --"p:P39"--> a1 v6 --"p:direct/P31"--> c2 v6 --"p:direct/P39"--> c4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:direct/P570".-> v7 end a2 --"p:statement/P39"--> c4 a2 --"p:qualifier/P580"--> v3 v6 --"p:P39"--> a2 a3 --"p:statement/P39"--> c4 a3 --"p:qualifier/P582"--> v1 v6 --"p:P39"--> a3 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; f2[["not "]] subgraph f2e0["Exists Clause"] e0v1 --"p:direct/P570"--> e0v2 e0v2("?died"):::projected e0v1("?oldperson"):::projected end f2--EXISTS--> f2e0 f2 --> v6 f2 --> c9 f2 --> v7 v6 --"p:direct/P570"--> v7 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; f3[["?newstart < ?died"]] f3 --> v5 f3 --> v7 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end