SPARQL Revision Metadata

Revisions figure in SPARQL operations in two ways:

  • metadata retrieval

  • query revision specification

Revision Metadata Retrieval via SPARQL

The service location <urn:dydra:timemap> yields the query repository’s revision timemap as a graph. Given this, a query such as

SELECT ?revision ?startTime
WHERE {
 { select ?bundle ?startTime where
   { SERVICE  <urn:dydra:timemap> { ?bundle ?predicate ?startTime . }
     filter(?predicate = <http://www.mementoweb.org/terms/tb/start>)
   } }
 { select ?bundle ?type where
   { SERVICE  <urn:dydra:timemap> { ?bundle ?predicate ?type }
   filter (?predicate = <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
           && ?type = <http://www.mementoweb.org/terms/tb/Period> )
   } }
 { select ?revision ?bundle where
   { SERVICE  <urn:dydra:timemap> { ?revision ?predicate ?bundle . }
   filter( ?predicate = <http://www.mementoweb.org/terms/tb/validOver> )
   } }
} order BY DESC (?startTime)

would yield the revision start dates for the respective repository.

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.