Definition

A named query is a SPARQL SELECT query that may be created and edited directly in Callimachus.

Purpose

Named queries provide “result sets” or answers to questions asked using the SPARQL Query Language. The result sets can be visualized as pie charts, line charts, annotations on Google maps and so on.

Creating named queries

To create a named query, select Named query using the create menu from the folder you wish to store the named query in. You will be presented with the following initial code:

#
# @Cache-Control:
# @view
#
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT * {
}

See Using Named Queries for more details.

Example Named Query

Here is an example of a named query that shows pollution levels over time.

    PREFIX owl: <http://www.w3.org/2002/07/owl#>
    PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
    PREFIX tri: <http://usepa.3roundstones.net/id/us/fed/agency/epa/tri/schema/>
    PREFIX : <#>

    SELECT DISTINCT ?year ?pounds
    WHERE {
    ?tri_facility owl:sameAs <http://usepa.3roundstones.net/facilities/110000484039>
    ; tri:has_report ?report .

    ?report tri:reports_release_of ?chem
    ; tri:reporting_year ?year
    ; tri:released_to ?location .

    ?chem skos:prefLabel “$chemical” .

    ?location tri:amount_in_pounds ?pounds
    ; tri:environmental_medium <http://usepa.3roundstones.net/id/us/fed/agency/epa/tri/environmental_medium/AIR_STACK> .

    } order by ?year

Here is the result set displayed as a graph.

Source: A Real-World Linked Open Data Story