Exemples de Requêtes Sparql

Requêtes générales et requêtes CIDOC-CRM

Préfixes

PREFIX ecrm: <http://erlangen-crm.org/150929/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

A. Requêtes basées sur le formalisme RDF

Liste des concepts utilisés.

SELECT Distinct ?concept
WHERE
{
[] rdf:type ?concept .
}
Order By ?concept

Nombre de concepts utilisés.

SELECT Distinct (Count(Distinct ?concept) As ?numberOfConcepts)
WHERE
{
[] rdf:type ?concept .
}

Liste des prédicats utilisés.

SELECT Distinct ?predicate
WHERE
{
?subject ?predicate ?object .
}
Order By ?predicate

Nombre de prédicats utilisés.

SELECT Distinct (Count(Distinct ?predicate) As ?numberOfPredicates)
WHERE
{
?subject ?predicate ?object .
}

Liste des triplets terminaux dont le noeud terminal est non vide.

SELECT Distinct ?subject ?predicate ?object
WHERE
{
?subject ?predicate ?object .
Filter ( isLiteral(?object) && ?object != "" )
}

Liste des prédicats terminaux dont le noeud terminal est non vide.

SELECT Distinct ?predicate
WHERE
{
?subject ?predicate ?object .
Filter ( isLiteral(?object) && ?object != "" )
}

Extraits de chemins menant vers des noeuds terminaux non vides.

SELECT ?object0 ?predicate0 ?subject0 ?predicate1 ?subject1 ?predicate2 ?subject2
WHERE
{
?subject0 ?predicate0 ?object0 .
Optional {
?subject1 ?predicate1 ?subject0 .
Optional {
?subject2 ?predicate2 ?subject1 .
}
}
Filter ( isLiteral(?object0) && ?object0 != "" )
}

Liste des triplets ayant pour sujet un noeud donné (exemples: http://erlangen-crm.org/150929/E39_Actor, http://dbpedia.org/resource/Venus_de_Milo, http://dbpedia.org/resource/Peter_Jackson).

SELECT ?subject ?predicate ?object
WHERE
{
?subject ?predicate ?object .
Filter ( ?subject = <http://erlangen-crm.org/150929/E39_Actor> )
}

B. Requêtes basées sur la norme CIDOC-CRM

Liste de labels non vides d'entités spécifiques en utilisant des classes génériques: type (E55_Type), titre (E35_Title), dimension (E54_Dimension), matériau (E57_Material), lieu/place (E53_Place), etc.

SELECT Distinct ?type
WHERE
{
?type_uri rdf:type ecrm:E55_Type .
?type_uri rdfs:label ?type .
Filter ( ?type != "" )
}

SELECT Distinct ?material
WHERE
{
?material_uri rdf:type ecrm:E57_Material .
?material_uri rdfs:label ?material .
Filter ( ?material != "" )
}

Liste de labels non vides d'entités spécifiques en utilisant des propriétés: type (P2_has_type), titre (P102_has_title), dimension (P43_has_dimension), matériau (P45_consists_of), lieu/place (P87_is_identified_by), etc.

SELECT Distinct ?subject ?title
WHERE
{
?subject ecrm:P102_has_title ?title_uri .
?title_uri rdfs:label ?title .
Filter ( ?title != "" )
}

SELECT Distinct ?subject ?place
WHERE
{
?subject ecrm:P87_is_identified_by ?place_uri .
?place_uri rdfs:label ?place .
Filter ( ?place != "" )
}

Liste de caractéristiques (identifiant, type, note, etc.) provenant de l'entité racine "E1 CRM Entity".

SELECT Distinct ?id1 ?id2 ?type ?description
WHERE
{
?e1_obj ecrm:P48_has_preferred_identifier ?id1_uri .
?id1_uri rdfs:label ?id1 .
?e1_obj ecrm:P1_is_identified_by ?id2_uri .
?id2_uri rdfs:label ?id2 .
?e1_obj ecrm:P2_has_type ?type_uri .
?type_uri rdfs:label ?type .
?e1_obj ecrm:P3_has_note ?description .
}

Liste de caractéristiques (dimension, titre, matériau) qui proviennent d'entités persistantes (différentes de l'entité racine "E1 CRM Entity").

SELECT Distinct ?id1 ?dimensions ?title ?material
WHERE
{
?obj ecrm:P48_has_preferred_identifier ?id1_uri .
?id1_uri rdfs:label ?id1 .

?obj ecrm:P43_has_dimension ?dimensions_uri .
?dimensions_uri rdfs:label ?dimensions .
?obj ecrm:P102_has_title ?title_uri .
?title_uri rdfs:label ?title .
?obj ecrm:P45_consists_of ?material_uri .
?material_uri rdfs:label ?material .
}

Datation (date) d'origine des objets.

SELECT Distinct ?id1 ?time_span_uri ?dateOrigin
WHERE
{
?obj ecrm:P48_has_preferred_identifier ?id1_uri .
?id1_uri rdfs:label ?id1 .

?obj ecrm:P92i_was_brought_into_existence_by ?e63_beginning_of_existence .

?e63_beginning_of_existence ecrm:P4_has_time-span ?time_span_uri .
?time_span_uri ecrm:P78_is_identified_by ?time_appellation_uri .
?time_appellation_uri rdfs:label ?dateOrigin .

Filter ( ?dateOrigin != "" )
}

Origine des objets (date, lieu, participants).

SELECT Distinct ?id1 ?dateOrigin ?placeOrigin ?actorOrigin
WHERE
{
?obj ecrm:P48_has_preferred_identifier ?id1_uri .
?id1_uri rdfs:label ?id1 .

?obj ecrm:P92i_was_brought_into_existence_by ?e63_beginning_of_existence .

?e63_beginning_of_existence ecrm:P4_has_time-span ?time_span_uri .
?time_span_uri ecrm:P78_is_identified_by ?time_appellation_uri .
?time_appellation_uri rdfs:label ?dateOrigin .

?e63_beginning_of_existence ecrm:P7_took_place_at ?place_uri .
?place_uri ecrm:P87_is_identified_by ?place_appellation_uri .
?place_appellation_uri rdfs:label ?placeOrigin .

?e63_beginning_of_existence ecrm:P11_had_participant ?actor_uri .
?actor_uri rdfs:label ?actorOrigin .
}

Localisation (lieux) de Garde des objects.

SELECT Distinct ?place_custody_uri ?placeCustody
WHERE
{
?obj ecrm:P30i_custody_transferred_through ?e10_transfer_of_custody .

?e10_transfer_of_custody ecrm:P7_took_place_at ?place_custody_uri .
?place_custody_uri ecrm:P87_is_identified_by ?place_appellation_custody_uri .
?place_appellation_custody_uri rdfs:label ?placeCustody .

Filter ( ?placeCustody != "" )
}

Transfert de Garde des objects (date, lieu, participants).

SELECT Distinct ?id1 ?dateCustody ?placeCustody ?actorCustody
WHERE
{
?obj ecrm:P48_has_preferred_identifier ?id1_uri .
?id1_uri rdfs:label ?id1 .

?obj ecrm:P30i_custody_transferred_through ?e10_transfer_of_custody .

?e10_transfer_of_custody ecrm:P4_has_time-span ?time_span_custody_uri .
?time_span_custody_uri ecrm:P78_is_identified_by ?time_appellation_custody_uri .
?time_appellation_custody_uri rdfs:label ?dateCustody .

?e10_transfer_of_custody ecrm:P7_took_place_at ?place_custody_uri .
?place_custody_uri ecrm:P87_is_identified_by ?place_custody_appellation_uri .
?place_custody_appellation_uri rdfs:label ?placeCustody .

?e10_transfer_of_custody ecrm:P11_had_participant ?actor_custody_uri .
?actor_custody_uri rdfs:label ?actorCustody .
}