Create virtual graph with multiple DB

Hi Team,

I could successfully create virtual graph from one database. Now, I want to create a single Virtual Graph using multiple databases. How can I do that? I saw in previous topics for the same and it said:
“Simply register each connection as its own virtual graph, and then you will be able to query over them seamlessly.”
I did not understand how to do it.
Can you please help me with the same?
Also, is it possible to preserve foreign key relationship in two different databases in one virtual graph?

Thank you!!

I tried creating a virtual graph by adding the main database which has foreign key reference as
jdbc.url as jdbc:mysql://127.0.0.1/myDB
and by giving sql.schemas as the name of the database that contains foreign key in the main db as
sql.schemas=externalDB

It shows an exception : There was an unexpected error on the server.

Is this the right way of doing it?

This refers to having access to multiple virtual graphs from a single Stardog database. You would register your second virtual graph the same way that you registered the first one

$ stardog-admin virtual add mydb2.properties mydb2.ttl

Then you can query across both virtual graphs from a single Stardog database

select * where { graph <virtual:mydb1> { ....} graph <virtual:mydb2> {...}}

I don't believe that virtual graphs participate in query.all.graphs so I don't think you can use that to try and make the two virtual graphs look like a single graph. (I've just don't recall checking for that behavior but it would be odd if it did since virtual graphs are global to the server)

Is there something in your use case that keeps you from querying across two separate graphs?

I'm really not quite sure. I didn't even know mysql supported that. (looked it up and it looks like they do. What do you know, you learn something new every day. Thanks). I'd guess that the constraint wouldn't really matter but the query might be another issue. I'd say give it a try. I'm sure the Stardog folks would be interested in the results.

You can make two resources from two separate databases map to the same resource which might achieve what you're looking for, I'm just not sure what you're looking for by "preserve foreign key relationship" but I think that's what you're looking for.

Hope this helps.

What was the exception? Anything interesting in the logs? I’m guessing you’d need to supply both schemas you’re querying against but that’s a total guess.

Hey thanks I will try creating that and update!!
Is there something in your use case that keeps you from querying across two separate graphs? : I can query them separately but i am trying foreign key relationship in 2 different db!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.