views:

138

answers:

2

I have a database that acts like a triple store, except that it is just a simple MySQL database.

I want to select all triples that have a common predicate and object. Info about RDF and triples

I can't seem to work out the SQL.

If I had just a single predicate and object to match I would do:

select TRIPLE from TRIPLES where PREDICATE="predicateName" and OBJECT="objectName"

But if I have a list (HashMap) of many pairs of (predicateName,objectName) I am not sure what I need to do.

Please let me know if I need to provide more info, I am not sure that I have made this quite clear, but I am wary of providing too much info and confusing the issue.

+1  A: 

Probably load your hashmap into a temporary table and do a JOIN to your triple store.

Bill Karwin
A: 

select TRIPLE from TRIPLES where PREDICATE in (?,?,?,........) and OBJECT in (?,?,?,?,.....)

Populate the `?'s using HashMap.keys and HashMap.values. Depending on language and data-access method, use either bound parameters (ODBC and other methods) or expand the parameters building up the sql yourself.

Tim