query-b3f856369cd6f2d5995d0f3000a1d802

rq turtle/ttl

Au 19 juillet 1976, il y a 101 départements. SELECT DISTINCT ?inseeDépartement ?département ?nom ?inseeRégion ?région ?inseeCheflieu ?cheflieu WHERE { BIND ( "1976-07-19"^^xsd:dateTime as ?dateRecherche )

?département p:P2586 ?P2586node . # existence d'un code Insee ?P2586node ps:P2586 ?inseeDépartement . # valeur du code Insee OPTIONAL { ?département wdt:P571 ?dateCréation . } # date de création OPTIONAL { ?département wdt:P576 ?dateDissolution . } # date de dissolution

?département p:P1448 ?P1448node . # existence d'un nom ?P1448node ps:P1448 ?nom . # valeur du nom FILTER( lang(?nom)="fr" ). # nom en français MINUS { ?P1448node pq:P2241 ?dépréciationNom . } # nom erroné OPTIONAL { ?P1448node pq:P580 ?dateDébutNom . } # date de début du nom OPTIONAL { ?P1448node pq:P582 ?dateFinNom . } # date de fin du nom

{ ?département p:P36 ?P36node . # existence d'un chef-lieu ?P36node ps:P36 ?cheflieu . # valeur du chef-lieu OPTIONAL { ?P36node pq:P580 ?dateDébutCheflieu . } # date de début du chef-lieu OPTIONAL { ?P36node pq:P582 ?dateFinCheflieu . } # date de fin du chef-lieu ?cheflieu p:P374 ?P374node . # existence d'un code Insee du chef-lieu ?P374node ps:P374 ?inseeCheflieu . # valeur du code Insee du chef-lieu OPTIONAL { ?P374node pq:P580 ?dateDébutCode . } # date de début du code Insee du chef-lieu OPTIONAL { ?P374node pq:P582 ?dateFinCode . } # date de fin du code Insee du chef-lieu } UNION { VALUES (?inseeDépartement ?département ?inseeCheflieu ?cheflieu ) {("75" wd:Q90 "75056" wd:Q90)} } # Paris

{ { ?région wdt:P2585 ?inseeRégion. # code Insee de la région ?cheflieu p:P131 ?P131nodeRégion . # région monodépartementale ?P131nodeRégion ps:P131 ?région . # valeur de la région } UNION { ?région wdt:P2585 ?inseeRégion. # code Insee de la région ?département p:P131 ?P131nodeRégion . ?P131nodeRégion ps:P131 ?région . # valeur de la région } OPTIONAL { ?P131nodeRégion pq:P580 ?dateDébutRégion . } # date de début de la région OPTIONAL { ?P131nodeRégion pq:P582 ?dateFinRégion . } # date de fin de la région } UNION { VALUES (?inseeDépartement ?département ) {("975" wd:Q124285017)} } # Saint-Pierre-et-Miquelon

FILTER ( !BOUND(?dateCréation) || ?dateCréation <= ?dateRecherche ) # départements futurs
FILTER ( !BOUND(?dateDissolution) || ?dateDissolution > ?dateRecherche ) # départements passés
FILTER ( !BOUND(?dateDébutRégion) || ?dateDébutRégion <= ?dateRecherche ) # ancienne région
FILTER ( !BOUND(?dateFinRégion) || ?dateFinRégion > ?dateRecherche ) # future région 
FILTER ( !BOUND(?dateDébutCheflieu) || ?dateDébutCheflieu <= ?dateRecherche ) # ancien chef-lieu
FILTER ( !BOUND(?dateFinCheflieu) || ?dateFinCheflieu > ?dateRecherche ) # futur chef-lieu  
FILTER ( !BOUND(?dateDébutCode) || ?dateDébutCode <= ?dateRecherche ) # ancien code Insee
FILTER ( !BOUND(?dateFinCode) || ?dateFinCode > ?dateRecherche ) # futur code Insee 
FILTER ( !BOUND(?dateDébutNom) || ?dateDébutNom <= ?dateRecherche ) # ancien nom
FILTER ( !BOUND(?dateFinNom) || ?dateFinNom > ?dateRecherche ) # futur nom

} ORDER BY ?inseeDépartement

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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/>
# Au 19 juillet 1976, il y a 101 départements.
SELECT DISTINCT ?inseeDépartement ?département ?nom ?inseeRégion ?région ?inseeCheflieu ?cheflieu WHERE {
  BIND ( "1976-07-19"^^xsd:date as ?dateRecherche ) 

   ?département p:P2586 ?P2586node . # existence d'un code Insee
    ?P2586node ps:P2586 ?inseeDépartement . # valeur du code Insee
    OPTIONAL { ?département wdt:P571 ?dateCréation . } # date de création
    OPTIONAL { ?département wdt:P576 ?dateDissolution . } # date de dissolution

   ?département p:P1448 ?P1448node . # existence d'un nom
    ?P1448node ps:P1448 ?nom . # valeur du nom
    FILTER( lang(?nom)="fr" ). # nom en français
    MINUS { ?P1448node pq:P2241 ?dépréciationNom . } # nom erroné
    OPTIONAL { ?P1448node pq:P580 ?dateDébutNom . } # date de début du nom
    OPTIONAL { ?P1448node pq:P582 ?dateFinNom . } # date de fin du nom 

   { ?département p:P36 ?P36node . # existence d'un chef-lieu
    ?P36node ps:P36 ?cheflieu . # valeur du chef-lieu
    OPTIONAL { ?P36node pq:P580 ?dateDébutCheflieu . } # date de début du chef-lieu
    OPTIONAL { ?P36node pq:P582 ?dateFinCheflieu . } # date de fin du chef-lieu 
    ?cheflieu p:P374 ?P374node . # existence d'un code Insee du chef-lieu
    ?P374node ps:P374 ?inseeCheflieu . # valeur du code Insee du chef-lieu
    OPTIONAL { ?P374node pq:P580 ?dateDébutCode . } # date de début du code Insee du chef-lieu
    OPTIONAL { ?P374node pq:P582 ?dateFinCode . } # date de fin du code Insee  du chef-lieu
    }
     UNION { VALUES (?inseeDépartement ?département ?inseeCheflieu ?cheflieu ) {("75" wd:Q90 "75056" wd:Q90)} } # Paris

   { { ?région wdt:P2585 ?inseeRégion. # code Insee de la région
     ?cheflieu p:P131 ?P131nodeRégion . # région monodépartementale
     ?P131nodeRégion ps:P131 ?région .  # valeur de la région
       }
     UNION { 
     ?région wdt:P2585 ?inseeRégion. # code Insee de la région
     ?département p:P131 ?P131nodeRégion .
     ?P131nodeRégion ps:P131 ?région .  # valeur de la région
       }
     OPTIONAL { ?P131nodeRégion pq:P580 ?dateDébutRégion . } # date de début de la région
     OPTIONAL { ?P131nodeRégion pq:P582 ?dateFinRégion . } # date de fin de la région
   } UNION { VALUES (?inseeDépartement ?département ) {("975" wd:Q124285017)} } # Saint-Pierre-et-Miquelon

    FILTER ( !BOUND(?dateCréation) || ?dateCréation <= ?dateRecherche ) # départements futurs
    FILTER ( !BOUND(?dateDissolution) || ?dateDissolution > ?dateRecherche ) # départements passés
    FILTER ( !BOUND(?dateDébutRégion) || ?dateDébutRégion <= ?dateRecherche ) # ancienne région
    FILTER ( !BOUND(?dateFinRégion) || ?dateFinRégion > ?dateRecherche ) # future région 
    FILTER ( !BOUND(?dateDébutCheflieu) || ?dateDébutCheflieu <= ?dateRecherche ) # ancien chef-lieu
    FILTER ( !BOUND(?dateFinCheflieu) || ?dateFinCheflieu > ?dateRecherche ) # futur chef-lieu  
    FILTER ( !BOUND(?dateDébutCode) || ?dateDébutCode <= ?dateRecherche ) # ancien code Insee
    FILTER ( !BOUND(?dateFinCode) || ?dateFinCode > ?dateRecherche ) # futur code Insee 
    FILTER ( !BOUND(?dateDébutNom) || ?dateDébutNom <= ?dateRecherche ) # ancien nom
    FILTER ( !BOUND(?dateFinNom) || ?dateFinNom > ?dateRecherche ) # futur nom   
}
ORDER BY ?inseeDépartement

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v24("?P131nodeRégion") v16("?P1448node") v15("?P2586node") v18("?P36node") v20("?P374node") v22("?cheflieu"):::projected v12("?dateCréation") v11("?dateDissolution") v8("?dateDébutCheflieu") v6("?dateDébutCode") v4("?dateDébutNom") v10("?dateDébutRégion") v7("?dateFinCheflieu") v5("?dateFinCode") v2("?dateFinNom") v9("?dateFinRégion") v14("?dateRecherche") v25("?département"):::projected v17("?dépréciationNom") v22("?inseeCheflieu"):::projected v25("?inseeDépartement"):::projected v23("?inseeRégion"):::projected v13("?nom"):::projected v22("?région"):::projected f0[["(not bound(?dateFinNom) || ?dateFinNom > ?dateRecherche)"]] f0 --> v2 f0 --> v14 f1[["(not bound(?dateDébutNom) || ?dateDébutNom <= ?dateRecherche)"]] f1 --> v4 f1 --> v14 f2[["(not bound(?dateFinCode) || ?dateFinCode > ?dateRecherche)"]] f2 --> v5 f2 --> v14 f3[["(not bound(?dateDébutCode) || ?dateDébutCode <= ?dateRecherche)"]] f3 --> v6 f3 --> v14 f4[["(not bound(?dateFinCheflieu) || ?dateFinCheflieu > ?dateRecherche)"]] f4 --> v7 f4 --> v14 f5[["(not bound(?dateDébutCheflieu) || ?dateDébutCheflieu <= ?dateRecherche)"]] f5 --> v8 f5 --> v14 f6[["(not bound(?dateFinRégion) || ?dateFinRégion > ?dateRecherche)"]] f6 --> v9 f6 --> v14 f7[["(not bound(?dateDébutRégion) || ?dateDébutRégion <= ?dateRecherche)"]] f7 --> v10 f7 --> v14 f8[["(not bound(?dateDissolution) || ?dateDissolution > ?dateRecherche)"]] f8 --> v11 f8 --> v14 f9[["(not bound(?dateCréation) || ?dateCréation <= ?dateRecherche)"]] f9 --> v12 f9 --> v14 f10[["?nom = 'fr'"]] f10 --> v13 bind11[/"'1976-07-19^^xsd:date'"/] bind11 --as--o v14 v25 --"p:P2586"--> v15 v15 --"p:statement/P2586"--> v25 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v25 -."p:direct/P571".-> v12 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v25 -."p:direct/P576".-> v11 end v25 --"p:P1448"--> v16 v16 --"p:statement/P1448"--> v13 subgraph minus12["MINUS"] style minus12 stroke-width:6px,fill:pink,stroke:red; v16 --"p:qualifier/P2241"--> v17 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v16 -."p:qualifier/P580".-> v4 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v16 -."p:qualifier/P582".-> v2 end subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; bind13[/VALUES ?cheflieu ?département ?inseeCheflieu ?inseeDépartement/] bind13-->v25 bind13-->v25 bind13-->v22 bind13-->v22 bind130(["75"]) bind130 --> bind13 bind131(["wd:Q90"]) bind131 --> bind13 bind132(["75056"]) bind132 --> bind13 bind133(["wd:Q90"]) bind133 --> bind13 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v25 --"p:P36"--> v18 v18 --"p:statement/P36"--> v22 subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v18 -."p:qualifier/P580".-> v8 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v18 -."p:qualifier/P582".-> v7 end v22 --"p:P374"--> v20 v20 --"p:statement/P374"--> v22 subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v20 -."p:qualifier/P580".-> v6 end subgraph optional7["(optional)"] style optional7 fill:#bbf,stroke-dasharray: 5 5; v20 -."p:qualifier/P582".-> v5 end end union0r <== or ==> union0l end subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; bind14[/VALUES ?département ?inseeDépartement/] bind14-->v25 bind14-->v25 bind140(["975"]) bind140 --> bind14 bind141(["wd:Q124285017"]) bind141 --> bind14 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; v22 --"p:direct/P2585"--> v23 v25 --"p:P131"--> v24 v24 --"p:statement/P131"--> v22 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v22 --"p:direct/P2585"--> v23 v22 --"p:P131"--> v24 v24 --"p:statement/P131"--> v22 end union2r <== or ==> union2l end subgraph optional8["(optional)"] style optional8 fill:#bbf,stroke-dasharray: 5 5; v24 -."p:qualifier/P580".-> v10 end subgraph optional9["(optional)"] style optional9 fill:#bbf,stroke-dasharray: 5 5; v24 -."p:qualifier/P582".-> v9 end end union1r <== or ==> union1l end