SPARQL Queries useful for DDG

This page contains various SPARQL queries that can be performed on the MICA triplestore in order to provide useful information in the DDG interface. Queries are sorted according to the type of resource to which they relate.

Concepts centric queries (TOC)

Get top level domain concepts (top level concepts in MICA main ontology)

Theses concepts are the concepts that have micavocab:MICA as parent concept.

Select all concepts which have micavocab:MICA as parent and for these concepts give the URI and label

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>

SELECT ?conceptURI ?label
WHERE {
    ?conceptURI a skos:Concept;
              skos:prefLabel ?label;
              skos:broader micavocab:MICA.
}

Get direct subconcepts of a given concept

In fact the previous query can be generalized to find all the direct sub-concepts of any given concept. For example :

Select all concepts which have micavocab:D1PrimaryResources as parent and for these concepts give the URI and label

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>

SELECT ?conceptURI ?label
WHERE {
    ?conceptURI a skos:Concept;
              skos:prefLabel ?label;
              skos:broader micavocab:D1PrimaryResources.
}

The previous query uses the skos:broader relation to retrieve the sub-concepts. It's also possible to uses the inverse relation skos:narrower.

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>

SELECT ?conceptURI ?label
WHERE {
    micavocab:D1PrimaryResources skos:narrower ?conceptURI.
    ?conceptURI skos:prefLabel ?label.
}

Get direct parent concept of a given concept

e.g. parent of concept micavocab:D1PrimaryResources

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>

SELECT   ?conceptURI  ?label
WHERE {
    micavocab:D1PrimaryResources skos:broader ?conceptURI.
    ?conceptURI skos:prefLabel ?label .
 }

The same query using skos:narrower instead of skos:broader

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>

SELECT   ?conceptURI  ?label
WHERE {
    ?conceptURI skos:narrower micavocab:D1PrimaryResources;
                skos:prefLabel ?label .
 }

Get all concepts of a given Concept scheme

e.g. Select all concepts of micavocab:DomainScheme

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>

SELECT ?conceptURI ?label 
WHERE {
   ?conceptURI a skos:Concept;
              skos:prefLabel ?label;
              skos:inScheme micavocab:DomainScheme.
  }

to get all the concepts of a concept scheme other than domain scheme just replace micavocab:DomainScheme URI by the corresponding MICA scheme URI.

  • micavocab:CommoditiesScheme for commodities concepts
  • micavocab:DataScheme for data concepts
  • micavocab:MethodsScheme for methods concepts
  • micavocab:SpatialScheme for spatial concepts
  • micavocab:TemporalScheme for temporal concepts
  • micavocab:ValueSupplyChainScheme for value supply chain concepts

Get statistics by concept

Not necessary! It can be done the query by type (factsheet, docsheet,… ) and count the results.

Get concept by concept URI

TODO: Ask Emanuela what she means.

Get all sheets of a given type directly related to a given concept

Select all factsheets (URI and title) directly related to domain concept micavocab:D1PrimaryResources

PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>
PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?sheetURI ?title
WHERE {
      ?sheetURI a model:FactSheet;
                dcterms:title ?title;
                model:hasDomainConcept micavocab:D1PrimaryResources .
}

For other type of sheets (docsheets, defsheets, flowsheet, external resource (data resource, linked data resource ...)) just replace model:FactSheet in the previous query by the corresponding data type defined in MicaModel ontology.

If the concept belongs to another concept scheme than domain scheme just replace model:hasDomainConcept property by the model:hasXXXConcept property corresponding to the appropriate concept scheme.

  • model:hasCommodityConcept for commodities concepts (micavocab:CommoditiesScheme)
  • model:hasDataConcept for data concepts (micavocab:DataScheme)
  • model:hasMethodConcept for methods concepts (micavocab:MethodsScheme)
  • model:hasSpatialConcept for spatial concepts micavocab:SpatialScheme
  • model:hasTemporalConcept for temporal concepts micavocab:TemporalScheme
  • model:hasValueSupplyChainConcept for value supply chain concepts micavocab:ValueSupplyChainScheme

TODO see how inferences canc be performed to use generic hasMicaConcept property instead of the specialized properties hasDomainConcept hasDataConcept ....

e.g. Get all docsheets (URI and title) related to the Value Supply Chain concept micavocab:Metallurgy

PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>
PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?sheetURI ?title
WHERE {
  ?sheetURI a model:DocSheet;
            dcterms:title ?title;
            model:hasValueSupplyChainConcept micavocab:Metallurgy .
}

e.g. get all legislations (URI and title) related to a domain concept "D1PrimaryResources"

PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>
PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT  ?legislation ?title
WHERE {
     ?legislation a model:LinkedDataResource;
                  dcterms:title ?title;
                  model:hasDomainConcept micavocab:D1PrimaryResources .
       }

TODO ask François Tertre if a specific subtype of LinkedDataResource must be defined for legislation ? or if LinkedDataResources always refer to a legislation.

Get all sheets of a given type related to a given domain concept (directly or undirectly i.e. through subconcepts)

e.g. find all factsheets (URI, title and concept label) related (directly or undirectly through subconcepts) to the domain concept micavocab:D1PrimaryResources

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>
PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?sheetURI ?title ?conceptLabel
WHERE {
    ?sheetURI a model:FactSheet;
               dcterms:title ?title;
               model:hasDomainConcept ?d.
    ?d skos:broaderTransitive micavocab:D1PrimaryResources;
       skos:prefLabel ?conceptLabel.
}

To search for an other type of sheet (e.g. DocSheet) just replace model:FactSheet by the appropriate corresponding data type defined in MicaModel ontology.

Get all questions related to a given domain concept

e.g. get all questions (URI , description) directly related to the domain concept micavocab:D1PrimaryResources

PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>
PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?questionURI ?description
WHERE {
    ?questionURI a model:Question;
            model:description ?description;
            model:hasDomainConcept micavocab:D1PrimaryResources .
}

Get all concepts of a given concept scheme related to a given concept .

Main ontology (domain) concepts and tranversal ontologies concepts are defined in different concept schemes.

e.g. get all domain concepts (URI , label) related to the domain concept micavocab:D1PrimaryResources

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>

SELECT ?conceptURI ?label
WHERE {
    ?conceptURI a skos:Concept;
                skos:prefLabel ?label;
                skos:inScheme micavocab:DomainScheme;
                skos:related micavocab:D1PrimaryResources.
}

to get all the concepts of a concept scheme other than domain scheme just replace micavocab:DomainScheme URI by the corresponding scheme URI MICA Scheme.

e.g. get all commodities concepts (URI , label) related to the domain concept micavocab:D1PrimaryResources

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>

SELECT ?conceptURI ?label
WHERE {
   ?conceptURI a skos:Concept;
               skos:prefLabel ?label;
               skos:inScheme micavocab:CommoditiesScheme;
               skos:related micavocab: D1PrimaryResources.
}

Get statistics by concept

TODO: Ask Emanuela what she means.

Get metadata (label definition, description, links …) for a given concept

TODO: Ask Emanuela what she exactly means by "concept metadata". Currently we only have skos:preflabel, skos:altLabel and skos:definition properties for concepts.

e.g. find URI, label and if they exist the definition and alternative labels of the domain concept micavocab:D1PrimaryResources

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT ?conceptURI ?label ?definition ?altLabel
WHERE {
    micavocab:D1PrimaryResources skos:prefLabel ?label.
    optional { micavocab:D1PrimaryResources skos:definition ?definition.}
    optional { micavocab:D1PrimaryResources skos:altLabel ?altLabel.}
}

Get all concepts containing a text in their label or definition or other available metadata

TODO: Ask Emanuela what she exactly means by "concept metadata". Currently we only have skos:preflabel, skos:altLabel and skos:definition properties for concepts.

e.g. find URI, label and if they exist the definition and alternative labels of all the concepts containing the text "drilling"

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT    ?conceptURI ?label ?definition ?altLabel
WHERE {
    ?conceptURI a skos:Concept;
           skos:prefLabel ?label.
    FILTER regex( ?label ,"drilling","i")
    optional{
       ?conceptURI skos:definition ?definition.
       FILTER regex( ?definition ,"drilling","i")
    }  
    optional{
       ?conceptURI skos:altLabel ?altLabel.
       FILTER regex( ?altLabel ,"drilling","i")
    } 
}

Sheets centric queries (TOC)

Sheets can be of any type: FactSheet, DocSheet, Legislation... See MicaModel ontology to get all the subtypes of sheets.

Get sheet by concepturi

TODO: Ask Emanuela what she exactly means

Get all sheets of a given type

e.g. get all factsheets (URI and title)

PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?sheetURI ?title
WHERE {
    ?sheetURI a model:FactSheet;
               dcterms:title ?title.
}

for other type of sheets just replace model:FactSheet by the appropriate MicaModel ontology data type. see types of sheets.

Get all sheets related to a given sheet

e.g. find all the factsheets related to the factsheet micaresource:FactSheetMineClosure

PREFIX micaresource: <https://w3id.org/mica/resource/>
PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?sheetURI ?title WHERE {
    ?sheetURI a model:FactSheet;
        dcterms:title ?title;
        model:relatedSheet micaresource:FactSheetMineClosure. 
}

For other type of sheets just replace model:FactSheet by the appropriate MicaModel ontology data type. see types of sheets.

For other type of resource just replace micaresource:FactSheetMineClosure by the corresponding URI of resource.

The following example represents every type of sheet:

  • DocSheet: micaresource:DocSheetStocksInUse
  • DefSheet: micaresource:DefSheetCircularEconomy
  • FlowSheet: micaresource:FlowSheetValueAdded
  • LinkedDataResource: micaresource:LinkedDataResourceEndOfLifeWaste
  • MicaDataResource: micaresource:MicaDataResourceGlassWaste
  • WebDocumentResource: micaresource:WebDocumentResourceWebsite

e.g find all factsheets related to the docSheet micaresource:DocSheetStocksInUse

PREFIX micaresource: <https://w3id.org/mica/resource/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>
PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?sheetURI ?title WHERE {
  ?sheetURI a model:FactSheet;
             dcterms:title ?title;
             model:relatedSheet micaresource:DocSheetStocksInUse. 
}

Get all the questions related to a given sheet

eg get all the questions (URI and description) related to the factsheet micaresource:FactSheetMineClosure

PREFIX micaresource: <https://w3id.org/mica/resource/>
PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?questionURI ?description 
WHERE {
    ?questionURI a model:Question;
              model:description ?description.
    micaresource:FactSheetMineClosure model:answerTo ?questionURI.  
}

Get all concepts of a given concept scheme related to a given sheet

e.g. get all domain concepts (URI and label) related to the factsheet micaresource:FactSheetMineClosure

PREFIX micaresource: <https://w3id.org/mica/resource/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>

SELECT ?conceptURI ?label
WHERE {
    micaresource:FactSheetMineClosure model:hasDomainConcept ?conceptURI .
    ?conceptURI a skos:Concept;
            skos:prefLabel ?label.  
}

To get all the concepts of a concept scheme other than domain scheme just replace model:hasDomainConcept property by the model:hasXXXConcept property corresponding to the appropriate concept scheme.

  • model:hasCommodityConcept for commodities concepts (micavocab:CommoditiesScheme)
  • model:hasDataConcept for data concepts (micavocab:DataScheme)
  • model:hasMethodConcept for methods concepts (micavocab:MethodsScheme)
  • model:hasSpatialConcept for spatial concepts micavocab:SpatialScheme
  • model:hasTemporalConcept for temporal concepts micavocab:TemporalScheme
  • model:hasValueSupplyChainConcept for value supply chain concepts micavocab:ValueSupplyChainScheme

    e.g. get all commodities concepts (URI and label) related to the factsheet micaresource:FactSheetMineClosure

    PREFIX micaresource: <https://w3id.org/mica/resource/>
    PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
    PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
    
    SELECT ?conceptURI ?label
    WHERE {
        micaresource:FactSheetMineClosure   model:hasCommodityConcept ?conceptURI .
        ?conceptURI a skos:Concept;
                    skos:prefLabel ?label.  
    }
    

Get statistics by sheet

TODO: Ask Emanuela what she means.

Get all sheets of a given type containing a text in their title or description or other available metadata.

e.g. find all factsheets (URI, title and if it exists description) containing the text "de"

prefix micamodel: <https://w3id.org/mica/ontology/MicaModel#>
prefix dcterms: <http://purl.org/dc/terms/>

SELECT ?sheetURI ?title ?description
WHERE {
    ?sheetURI a micamodel:FactSheet;
              dcterms:title ?title.
              FILTER regex( ?title ,"de","i")
    optional{
        ?sheetURI micamodel:description ?description.
        FILTER regex( ?description ,"de","i")
    }      
}

for other types of sheets just replace model:FactSheet by the appropriate MicaModel ontology data type. see types of sheets.


Questions centric queries (TOC)

Get question by concepturi

TODO: Ask Emanuela what she means.

Get all questions (URI and description)

 PREFIX :   <https://w3id.org/mica/resource/factsheet/>
 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
 PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
 PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
 PREFIX dcterms: <http://purl.org/dc/terms/>

 SELECT DISTINCT ?questionURI ?description
 WHERE {
    ?questionURI a model:Question;
        model:description ?description.
 }

Get all sheets related to a given question

e.g. get all factsheets (URI and title) related to the question micaresource:QuestionPrimaryResources

PREFIX micaresource: <https://w3id.org/mica/resource/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>
PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?sheetURI ?title WHERE {
  ?sheetURI a model:FactSheet;
            dcterms:title ?title;
            model:answersTo micaresource:QuestionPrimaryResources. 
}

for other types of sheets just replace model:FactSheet by the appropriate MicaModel ontology data type. see types of sheets.

e.g. get all legislation related to the question micaresource:QuestionPrimaryResources

PREFIX micaresource: <https://w3id.org/mica/resource/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>
PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?sheetURI ?title WHERE {
  ?sheetURI a model:LinkedDataResource;
            dcterms:title ?title;
            model:answersTo micaresource:QuestionPrimaryResources.
}

TODO ask François Tertre if a specific subtype of LinkedDataResource must be defined for legislation ? or if LinkedDataResources always refer to a legislation.

Get list question to a question

TODO: Ask Emanuela what she means.

Get statistics by question

TODO: Ask Emanuela what she means. What kind of statistics ? e.g number of sheets directly responding to a question ? number of related concepts. SPARQL has some aggregation functions that can help to perform such queries.

Get all metadata (definition, description, links …) about a given question

TODO: Ask Emanuela what she expects. What does she mean by definition. In the current MICA data model we only have a description. Futhermore, what does she mean by links.

e.g. get the description of the question micaresource:QuestionPrimaryResources

PREFIX micaresource: <https://w3id.org/mica/resource/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX micavocab: <https://w3id.org/mica/ontology/MicaOntology/>
PREFIX model: <https://w3id.org/mica/ontology/MicaModel#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?description
WHERE {
  micaresource:QuestionPrimaryResources   model:description  ?description.
}

Get all questions containing a given text in their description

e.g. get all questions containing the text "mining waste"

prefix micamodel: <https://w3id.org/mica/ontology/MicaModel#>
prefix dcterms: <http://purl.org/dc/terms/>

SELECT    ?questionURI ?description
WHERE {
 ?questionURI a micamodel:Question;
    micamodel:description ?description.
    FILTER regex( ?description ,"mining waste","i")
}

(TOC)