Dynamically Merging Multiple Named Graphs?

I’m trying to find a good way to contextualize RDF statements (so that
statements could be bound to a certain time period, licensing terms, etc).
Named graphs seem to handle this pretty well.  But I can’t find a good way
to query across all named graphs which match some criteria.

I’ll try to illustrate the issue I’m facing via an example.  Suppose we have
the following graphs:

  @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
  @prefix xsd: <http://www.w3.org/2001/XMLSchema#>
  @prefix ex: <http://example.org/vocabulary#> .
  @prefix : <http://example.org/exampleDocument#>

  # default graph
  {
    <urn:g1> ex:startDate "1809-02-12T00:00:00Z"^^xsd:dateTime .
    <urn:g1> ex:endDate "1865-04-15T00:00:00Z"^^xsd:dateTime .
    <urn:g2> ex:startDate "1839-02-12T00:00:00Z"^^xsd:dateTime .
    <urn:g2> ex:endDate "1840-02-12T00:00:00Z"^^xsd:dateTime .
    <urn:g3> ex:startDate "1840-02-12T00:00:00Z"^^xsd:dateTime .
    <urn:g3> ex:endDate "1841-02-12T00:00:00Z"^^xsd:dateTime .
  }

  <urn:g1> {
    :Abraham_Lincoln rdf:type ex:LivingPerson .
  }

  <urn:g2> {
    :Abraham_Lincoln ex:age "30"^^http://www.w3.org/2001/XMLSchema#integer ..
  }

  <urn:g3> {
    :Abraham_Lincoln ex:age "31"^^http://www.w3.org/2001/XMLSchema#integer ..
  }

(So the default graph just contains “context information” and the “real” data is in the named graphs.)

Now suppose that I want to write a query to get the age of all living persons on a particular day.
In other words, I'd like to do something kind of like this:

  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
  PREFIX ex: <http://example.org/vocabulary#>
  PREFIX : <http://example.org/exampleDocument#>

  SELECT ?person $age
  WHERE {
    GRAPH ?g {
      ?person rdf:type ex:LivingPerson .
      ?person ex:age ?age .
    }
    ?g ex:startDate ?ctx_startDate .
    ?g ex:endDate ?ctx_endDate .
    FILTER (("1840-04-01T00:00:00Z"^^xsd:dateTime >= xsd:dateTime(?ctx_startDate)) &&
            ("1840-04-01T00:00:00Z"^^xsd:dateTime <= xsd:dateTime(?ctx_endDate)))
  }

....except that won't work, since the "rdf:type ex:LivingPerson" and "ex:age 31" assertions
live in two different graphs (even though each of those graphs represents a context which
does contain April 1, 1840).

Is there some way to make this work?  Essentially, I think I'm looking for a way to
have a query construct a dynamic merge of named graphs (without having to know the names
of those graphs up-front).

I’ve looked at the proposal for Composite Datasets
(http://www.w3.org/2009/sparql/wiki/Feature:CompositeDatasets), and it sounds somewhat
like what I’m seeking.  But even with it, it sounds like I’d need to explicitly specify
the graphs which I wanted to merge (instead of being able to just specify criteria about
them, and letting the system find them).  Correct?

Also, I should note that I’m fairly new to semantic web technologies.  So my apologies
In advance if I’ve botched any of the above syntax or am just approaching this in a screwy
way.

Thanks,
Jamey

Received on Monday, 24 August 2009 07:17:08 UTC