SPARQL Revision Metadata

Revisions figure in SPARQL operations in two ways:

  • metadata retrieval
  • query revision specification

Revision Metadata Retrieval via SPARQL

The named graph <urn:dydra:timemap> comprises the query’s repository as a named graph. Given this, a query such as

SELECT ( count(*) as ?revisionCount )
WHERE {
 GRAPH  <urn:dydra:timemap> {
   ?revisionId a <urn:dydra:Revision> .
 }
}

would yield the revision count for the respective repository. In a similar fashion

SELECT ?revisionId
WHERE {
  GRAPH  <urn:dydra:timemap> {
    ?revisionId a <urn:dydra:Revision> .
    ?revisionId <http://www.mementoweb.org/terms/tb/start> ?startTime .
  }
} ORDER BY DESC (?startTime)
  LIMIT 1

yields the uuid designator for the current revision, and

SELECT ?revisionId
WHERE {
  GRAPH  <urn:dydra:timemap> {
    ?revisionId a <urn:dydra:Revision> .
    ?revisionId <http://www.mementoweb.org/terms/tb/start> ?startTime .
  }
} ORDER BY DESC (?startTime)
  OFFSET 1
  LIMIT 1

that for the previous revision.

Revision Specification via SPARQL

Where no revision is specified, a SPARQL query is applied to the most current revision of a given repository. In order to specify a particular revision, specify its UUID for a revisionId pragma or as the value to the query argument revision-id in the protocol request. For example, an in-line specification would take the form

PREFIX revisionId : <urn:dydra:revision:a7b7ff5d-a73d-1545-be41-275337a28d70>
SELECT ( count(*) as ?statementCount )
WHERE { ?s ?p ?o }

while, in order to specify the revision independent of the query text, the equivalent SPARQL protocol request would be

GET /account/repository/sparql? \
  revision-id=%3Curn%3Adydra%3Arevision%3Aa7b7ff5d-a73d-1545-be41-275337a28d70%3E& \
  query=SELECT%20(%20count(*)%20as%20%3FstatementCount%20)%0A%20%20WHERE%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D \
  HTTP/1.1
Host: dydra.com

A specific revision is permitted for read-only queries only. Update operations apply to the current revision only.

Table Of Contents

Previous topic

HTTP Revision Metadata

Next topic

Service Access Authorization