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 as the value to the query argument revision-id in the protocol request. For example, a SPARQL protocol request would be

GET /account/repository/sparql? \
  revision-id=urn%3Adydra%3Arevision%3Aa7b7ff5d-a73d-1545-be41-275337a28d70& \
  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.