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.

Ankur
  • 50,282
  • 110
  • 242
  • 312

2 Answers2

1

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

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
0

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
  • 1