Multiple data sources to a virtual graph

Hi Team,

I'm new to stardog and trying to explore the capabilities of Stardog by creating some proof of concepts, with trial version of Stardog installed in the VM.

Is there a way to connect multiple database to a same virtual graph ?

If not, is there a way we would be able to connect multiple virtual graphs of different data sources ( like virtual graph A connected to MySQL with virtual graph B connected to a MongoDB ) ?

Is there any tutorial/document describing these ?

Appreciate for any help

Thanks,
Muthu

Hi Muthu,

Thanks for your question. A virtual graph in Stardog is defined against a single data source. You can learn about virtual graphs from some of the following resources:

Creating virtual graphs over multiple data sources is the basis for connecting data from otherwise independent data sources. You can create a virtual graph A connected to MySQL and virtual graph B connected to MongoDB and reference these virtual graphs in your query via GRAPH keyword or SPARQL's dataset (FROM and FROM NAMED).

I hope this helps. Let us know how it goes or if you have any further questions.

Jess

Thanks jess.

Is it possible to combine two virtual graphs of different data sources by referncing with a sparql query as you told?

I'm unable to combine two virtual graphs of different data sources ( 1 virtual graph of mongodb and other virtual graph of mysql ). please advise if i'm missing anything..

in below image - moviedateset virtual graph is source from mongodb, testmusic virtl graph has a source of mysql db

image

I'm able to combine two virtual graphs of same data source ( 2 mysql db's ) and get a response like below

What is preventing you from querying two sources of different types? Is there an error? Have you checked stardog.log on your server?

Hi jess,

Yeah i tried checking the logs, but no error.

I'm not getting the result and only empty result as displayed as shown below.

If i query both virtual graphs separately I'm getting the results.
but empty results are returned only while combining 2 virtual graph of 2 different data sources in a SPARQL query.

Please advice..

Can you share the query plan in text format please?

SELECT * {
GRAPH virtual://testmusic {
?band a :Band ;
:name "The Beatles" .
?member :member ?band ;
:name ?name .
}
GRAPH virtual://moviedataset {
?s ?p ?o
}
}

testmusic - mysql db - virtual graph

moviedataset - mongodb connected virtual graph

You will need to click the "Show Plan" button at the top.

Sorry , new to this... Getting 2 different query plans for same query based on selected Stardog database in the editor.

Below is the query plan if i select "testmusic" Stardog db in the editor

Slice(offset=0, limit=1000) [#2]
`─ Projection(?band, ?member, ?name, ?s, ?p, ?o) [#2]
   `─ NestedLoopJoin(_) [#2]
      +─ Scan[OSP](?s, ?p, ?o){<virtual://moviedataset>} [#1]
      `─ VirtualGraphSql<virtual://testmusic> [#1] {
         +─ RelNode=
         +─    LogicalProject(artist=[$0], band=[$1], name=[$3])
         +─      LogicalJoin(condition=[AND(=($1, $6), =($7, 'The Beatles'), =($9, 2))], joinType=[inner])
         +─        LogicalJoin(condition=[AND(=($0, $2), IS NOT NULL($3))], joinType=[inner])
         +─          JdbcTableScan(table=[[music, Membership]])
         +─          JdbcTableScan(table=[[music, Artist]])
         +─        JdbcTableScan(table=[[music, Artist]])
         +─ Query=
         +─    SELECT `Membership`.`artist`, `Membership`.`band`, `Artist`.`name`
         +─    FROM `music`.`Membership`
         +─    INNER JOIN `music`.`Artist` ON `Membership`.`artist` = `Artist`.`id` AND `Artist`.`name` IS NOT NULL
         +─    INNER JOIN `music`.`Artist` AS `Artist0` ON `Membership`.`band` = `Artist0`.`id` AND `Artist0`.`name` = 'The Beatles' AND `Artist0`.`type` = 2
         +─ Vars=
         +─    ?band <- TEMPLATE(http://stardog.com/tutorial/Artist{band/1})
         +─    ?member <- TEMPLATE(http://stardog.com/tutorial/Artist{artist/0})
         +─    ?name <- COLUMN($2)^^xsd:string
         }

Below is the query plan if i select "moviedatabase" Stardog db in the editor

Slice(offset=0, limit=1000) [#1]
`─ Projection(?band, ?member, ?name, ?s, ?p, ?o) [#1]
   `─ Empty [#1]

Hi @jess, Any suggestion or thought for this could be a help ?

Hi Muthu,

Thanks for following up. I must have missed your previous reply. There can be only one explanation here (famous last words...). A virtual graph may be configured to be logically contained within a database. This is configured with the "Stardog Database" field in the virtual graph configuration. Here's an example:

If you set this field to "All Databases", the virtual graph can be queried from any database. If you choose a single database, the virtual graph is considered to be contained in the database and can only be queried from that database. It seems you must have set this field to the "testmusic" database and therefore the virtual graphs cannot be queried from the "moviedatabase" database.

Hope this helps.
Jess

Thank you.. this worked

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