Creating RDF for 2 related tables and run SPARQL query on them

Following are my 2 tables:

    "id"            integer NOT NULL,   -- Primary key
    "tags"          varchar(500),
    "rootNode"      integer NOT NULL    -- Referes to Node table's "id"
    "id"            integer NOT NULL,   -- Primary key
    "parent"        integer NOT NULL,
    "owner"         varchar(500),
    "data"          varchar(500),
    "tags"          varchar(500)

The common RDF file that I have created for these is as follows:

<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="" xmlns:wp="">
    <wp:WPS rdf:about="">
    <wp:node><rdf:Description>  <wp:id>0</wp:id><wp:parent>-1</wp:parent><wp:owner>Kumar</wp:owner><wp:data>--#ABCDEFGHIJKLMNOPQRSTUVWXYZ#--</wp:data><wp:tags>MyTag</wp:tags></rdf:Description></wp:node>
    <wp:tree><rdf:Description>  <wp:treeId>814</wp:treeId><wp:treeTags>Banking</wp:treeTags><wp:rootNode>19989</wp:rootNode></rdf:Description></wp:tree>

Is this correct way of creating a combined rdf file for these 2 tables?

Now I want to run SPQRQL query similar to following SQL query:

select, w.tags, w.owner from Node w, Tree t where;

I tried using following query using FILTER but could not get the desired result. What is the correct way to do this?

    PREFIX wp: <> 
              SELECT ?x ?id 
              WHERE { 
                ?x wp:id ?id .
                ?x wp:trailId ?trailId .
                ?x wp:rootWP ?rootWP .
                FILTER (?trailId = 100)
                FILTER (?rootWP = ?id)


Generally speaking, you should not create database table structures yourself for storing RDF triples. It's a complex thing to get right, and even more difficult to make it performant. If you just want to create a persistent triple store, use the built-in capabilities of your RDF platform. In the case of Jena, this would be TDB or SDB.

Alternatively, if you need to have your data stored in a relational schema, but you also want to see that data as RDF triples so that you can query it with SPARQL, you need a relational-to-RDF mapping tool. There is standardisation work in this area, and open-source implementations such as D2RQ

Need Your Help

How to share json data between jquery mobile pages with out using window object

javascript jquery json jquery-mobile jquery-mobile-listview

In index.html page on "pageinit" event, I am getting all the employees details from the back end.

Addition not working in c

c printf addition format-specifiers

I was trying c code to add but my program doesn't execute, codeblocks unfortunately closes. What is the error?