I am not too experienced, bare with me please...
I have three classes A, B and C. The ABox contains triples like:
objA does objB
objB uses objC
Then it is inferred objA uses objC.
I need to extract this from Stardog with a Java application, to end up creating a JSON tree structure for Javascript. Actually, I need two trees:
1. One with objA being the root, all its children objB (coming from objA does objB) in the second level, and all objC (coming from objB uses objC) in the third level.
2. Another one with objA being the root, all its children objC (coming from the inferred objA uses objC) in the second level, and all objB (coming from objB uses objC) in the third level.
My question (perhaps basic) is how I can extract this efficiently from Stardog. I know I could do a query:
SELECT ?objB WHERE { <objA> does ?objB }
And then do one query per each objB obtained:
SELECT ?objC WHERE { <objB> uses ?objC }
Then do the same for tree (2), or, if Javascript performs faster, somehow create a function that swaps level 2 and 3 in the JSON.
This seems to me that it will perform badly because I need to query Stardog a lot of times ( one to get all Bs + one per each B to get all Cs). My question is: is there an alternative faster way to do this in Stardog? Sorry because I have no knowledge of Gremlin or TinkerPop3 - if they can be useful in here at all.
Thanks.