[Mulgara-general] dates in an RDF mulgara model...

Paul Gearon gearon at ieee.org
Thu Dec 4 19:30:05 UTC 2008


On Thu, Dec 4, 2008 at 12:33 PM, Hernandez, Genaro (NIH/OD) [E]
<hernange at od.nih.gov> wrote:
> Hi. I'm hoping that anyone out there in the Mulgara community can help
> me. My "Original Message" below was answered by Paul. But there are some
> things I don't understand about his answer. I don't know what are
> filters.

Ah, OK. My original answer didn't involve filters, and hence was
Mulgara specific.

When using SPARQL, you can constrain matches to patterns through the
use of filters. In this case, you can filter for a date variable being
less than (<) a given date. Note that this ONLY works on xsd:dateTimes
and not xsd:date (it is possible to convert these on the fly, but it's
not fast).  An example is:

prefix xsd: <http://www.w3.org/2001/XMLSchema#>
select $n
where {
   $n <...dateCreated> $d FILTER ($d < "2000-01-01T00:00:00Z"^^xsd:dateTime) }
}

We don't support filters in TQL (we could, but there's been no need).
However, they are in SPARQL.

> But I have seen emails concerning this topic. I looked for
> documentation but was unsuccessful. Can someone point me to online
> documentation about filters so I can learn about them?

Section 3 of the SPARQL spec gives an easy introduction to filters:
http://www.w3.org/TR/rdf-sparql-query/#termConstraint

Section 11 gives a more formal definition:
http://www.w3.org/TR/rdf-sparql-query/#tests

> I also want to know if someone can point me to some documentation where
> I can learn to perform queries on dates? For example, see the query
> below. The query has a ":before" which I'm unfamiliar with.

Ah, that's highly Mulgara specific.

The <mulgara:before> predicate is only relevant to the <sys:xsd>
graph. This is a virtual graph of relationships between XSD values. It
is calculated based on all the XSD typed values that have been stored
in the system. Because it's virtual, we can have literals in the
subject position of a triple.

The section of SPARQL where I refer to this is:

GRAPH <sys:xsd> { $d mulgara:before "2000-01-01"^^xsd:date }

The part saying "GRAPH <sys:xsd>" tells the system to look for this
data in the virtual graph named sys:xsd. The part that says "$d
mulgara:before "2000-01-01"^^xsd:date" will resolve to $d being bound
to every date that is before (or "less than") the given date. This is
explained in more detail in:
http://docs.mulgara.org/itqloperations/datatypingmodels.html

Note that this page is out of date. You no longer need to create your
own XSD Schema model. Use the <sys:xsd> graph instead.

> I hope someone out there can respond to my email.

Did this answer your questions?

Regards,
Paul Gearon



More information about the Mulgara-general mailing list