Re: Storing RDF in relational databases

Sergey Melnik wrote:
> 
> Could you cut-and-paste a couple of SQL statements that you use to query
> the DB? For example, how do you select all triples with a given subject
> (think of reification)?

I am using the same sequence for both reified statements and other
resources.  
The subj ID could be either a atatement ID, a resource ID or an internal
ID.

First, get the id from the id from the URI:

                 select id, value, isprefix, lang
		 from resources
		 where uri=$euri

If not found, see if it is a statement, and if not,
extract the id from the uri it it is a local uri. Else, fail.
The id for the uri will be cached. And the resource will be
represented by an object with a number of methods.

Then. Just select the statements:

                  select id
		  from statements
		  where subj = $subj_id

This method will return a reference to a list of statement objects.
Every statement object will consist of references to its resource
objects.


-- 
/ Jonas  -  http://paranormal.o.se/myself/cv/index.html

Received on Monday, 15 November 1999 02:22:19 UTC