On Sun, 2014-03-30 at 09:37 +0000, Kamalraj Jairam wrote: > Hello All, > > Whats the best way to convert sparql to SQL using R2RML mappings > > and convert resultset from DB to RDF? >
What are the givens? Do you have existing SPARQL text written against some RDF produced by some existing R2RML mappings? Or do you have some SPARQL and some SQL and you want to fill in the R2RML and produce some RDF? In any case, it is an interesting scenario that will arise more often as companies expand their use of RDF while relying mostly on SQL. There is a higher abstraction that should be explored and possibly exploited to provide a general pattern for working through these situations. Since SQL, SPARQL, and R2RML are rule languages compatible with relational algebra (RA), it should be possible to derive a common set of RA predicates and classes to create an RDF vocabulary. This vocabulary can then be used to write queries as production rules in a generic standard rule language, such as RIF (Rule Interchange Format). The RIF source can be translated to SQL, SPARQL, or R2RML for execution in the target system. Going from RIF to SQL, SPARQL, or R2RML is always going to be easier than starting from SQL or SPARQL and going to some other format. Theoretically you should be able to partially translate R2RML to RIF automatically (SQL embedded in the R2RML will still be opaque). But I don't know what tools could be used to translate SQL and SPARQL texts to generic production rules using an RA vocabulary. The ultimate payoff from this approach is that it will be possible to link all of your data relations and operations with meaningful business terminology and processes. It will enable greater visibility and control of all data operations, and put important elements of business logic in transparent rules (e.g. RIF) instead of arcane notations such as SQL SPARQL (or worse, procedural code). Regards, --Paul