Mapping succeed but ends up with an un-queriable virtual graph

Dear all,

By following the Using Virtual Graph tutorial, I created a mysql database "music" (I used music_schema.sql and beatles.sql). I then created an empty stardog database "music" by executing

stardog-admin db create -n music

I then successfully mapped the mysql database to a virtual graph in stardog by executing

$ stardog-admin virtual add music.properties music_mappings.ttl

After that, even though in stardog studio, the "music" virtual graph was there under the "VIRTUAL GRAPHS" tab, however, the database "music" under the "DATABASES" tab was still empty. Besides, I got no results when I query

SELECT ?name {
       GRAPH <virtual://music> {
...

Of course I can load the database "music" with data (ttl file) so that it can be queried from database (not from virtual//music), but I assume that the purpose of mapping is to map the existing mysql database to the virtual graph so that the mysql data can be used by stardog directly without the need of being loaded again in the form of ttl file, right?

So it is strange that my successfully completed mapping ends up with an un-queriable virtual graph. Did I miss any steps?

Thanks,
Ying

Can you include the complete query that you executed against the virtual graph? Depending on what you put there it might be correct that it isn't returning any results. I'm assuming you've got some data in your database that you are expecting to be mapped and returned. Is there anything in the logs?

I'm guessing that the reason that studio is showing the database as empty is because it isn't including anything from virtual graphs because it would need to materialize the database just to figure out how much data is in there and defeat much of the purpose of having a virtual graph.

Hi Zachary,

Thanks for replying me. Here is the completed query

SELECT ?name {
   GRAPH <virtual://music> {
      ?artist a :Artist ;
                  :name ?name 
   }
}

It returns a column name "name", but there is no result, even though there are actually 5 rows of data in "Artist" data table, as I materialized the mysql database by using

before it was being mapped to virtual graph.

Is there anything that I can try to fix it?

Thanks,
Ying

Derp. Sorry I missed that you were following along the tutorial.

I'd try double checking that the data got loaded correctly into mysql with a "select * from Artist" etc.

Did you add the namespace? The tutorial doesn't use the stardog default namespace.

$ stardog namespace add --prefix "" --uri "http://stardog.com/tutorial/" music

Hi Zachary,

Yes. I double checked the data in mysql by using ""select * from Artist; " and it retured 5 rows. I also added the stardog namespace.

I think stardog recognize the virtual graph as it returns result for the following query,

SELECT ?year (count(?album) AS ?count) 
FROM <virtual://music> {
      ?album a :Album ;
             :date ?date ;
      BIND (year(?date) AS ?year)
} 
GROUP By ?year

The results are three rows,

year     count
"1963"     1
"1970"     1
"1971"     1

But for any other query examples from the tutorial involving "Artist", "Track", and any tables other than "Album", none of them worked. It's weird. Any suggestions are appreciated.

Thanks,
Ying

That is odd. Are you using the mapping file from stardog-tutorials/music_mappings.ttl at master · stardog-union/stardog-tutorials · GitHub ?

I would drop the virtual graph, add it back, and keep an eye on the logs. You could also check the mysql logs for anything strange.

Yes, that's the mapping file that I used. I tried removing virtual graph and adding it back, but no luck at all. Thanks for your help though.

Ying

Can you please share the query plan for the query which is not returning any results? Can you try removing the :name predicate from your query and let us know if any artists are returned?

It looks like there's no :Artist class mapped. You should be able to query :SoloArtist or :Band.

Hi Jess,

You are right! I tried Band, Song, and etc., and they all worked beautifully. I didn't read the mapping file carefully and assume that the class names would match the data table names, and it turns out not always the case. Now everything works great!

Thanks,
Ying

Hi Ying,

You can query for :Artist instances if you add the music schema [1] to your database and enable reasoning. Based on the schema Stardog will automatically figure out that it needs to retrieve the bands and the solo artists from the virtual graph.

Best,
Evren

[1] stardog-tutorials/music_schema.ttl at master · stardog-union/stardog-tutorials · GitHub