Ruby-RDF: Database and Query Support

Overview

RubyRDF is evolving some data query facilities. There is a PostgreSQL-based storage and query system, a generic RDF query engine that
works over the basicrdf API, and some Web Services code providing client and server tools for RDF query. This work is inadaquately
document and tested, and is far from complete. A screenshot of RDFAuthor
querying a RubyRDF RDF query server shows that something is working. The squish/ directory contains the
implementation details and some example scripts.

PostgreSQL data query

The basicrdf.rb code now provides
some simple support for storing RDF data in PostgreSQL
relational tables, and (in squish.rb for translating RDF
queries into suitable SQL. The latter code is a reworking
(pretty much a java2ruby transliteration) of the Inkling Java
Squish2SQL
tool, and is implemented in squish.rb alongside a parser for
the Squish RDF query language.

These facilities are not yet integrated into any kind of
comprehensive API. They do work reasonably well on the
commandline, though.

Data storage

RDF query

These assume you have a PostgreSQL database up
and running, with data organised as above, and that you've
some way of actually running the SQL queries that squish.rb
generates. One way is simply to pipe them into the
commandline tool 'psql'.

And again, as before, we can load up this data into our
PostgreSQL triples table. Here we show how to load it into
the same table. This would be more interesting if the RDFWeb
co-depiction dataset and the FOAF-Corp datasets actually
overlapped...

SELECT DISTINCT b1.value AS x, b2.value AS n FROM triples a1, resources b1, resources b2
WHERE
b1.key=a1.subject AND b2.key=a1.object AND a1.predicate = '-1296757095'
test3.squish also works against this dataset:
../squish/samples/test3.squish | psql rubytest1

The end.

Summary

The Ruby-RDF query and database support is minimalistic, but
suprisingly useful. You can pipe data from the Web into a
database and run RDF queries without your applications caring
anything about how the data is stored. This is rather
handy...