Getting all graphs from the DB

Hi!

Is it possible to obtain the list of all graphs in the database using SPARQL?

It seems that I can get the list of almost all graphs using select ?g { graph ?g { ?s ?p ?o } }, for example. But it doesn’t contain any <virtual://*> graphs (I know that it’s possible to get those using virtual list CLI command, but I’ve been wondering how far can SPARQL go in Stardog).

Hey Slava,

Technically a virtual graph isn’t part of the database. :slight_smile: Virtual graphs are a Stardog feature and not part of any standard specification. The way that we’ve currently implemented them is that they are available system wide. Additionally, we haven’t (yet?) exposed the virtual graph details to SPARQL queries. As you’ve observed, your query will only list graphs that are present in the local RDF index. If you can provide some more details about what information you need and how you plan to use it, I may be able to provide an alternative.

Jess

Well, my thoughts are: if I’m only using SPARQL to work with Stardog DB, and I have added/imported some data into virtual graphs, I must memorise the graph IRIs for them “on my side” – otherwise, I won’t be able to find out later what their IRIs are (without using a CLI tool) and access the data there.

That is, if I don’t really care about what specific graphs my query should access, I could just use select * { graph ?g { ?s ?p ?o ; a <ex:User> } } to get all user data from all non-default graphs. But since my user data is coming both from virtual and non-virtual graphs, I will have to memorise and explicitly specify the virtual graph IRIs in addition to using that ?g for non-virtual graphs in my query.

I understand that virtual graphs is purely a Stardog thing. Moreover, I don’t feel much discomfort working with them as they are now. But perhaps it would make sense to “seamlessly integrate” them into the whole system and not stop half way through :slight_smile: I think that this would allow developers (users of Stardog) to write more portable and compact SPARQL queries.

Slava,

We realize the importance of making virtual graph access more transparent with regard to SPARQL queries. We have this on our roadmap and are planning to address it in a future release.

Jess

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

Hey Slava,

Stardog 5.0 supports querying the system database with a special service. You can now query the list of virtual graphs like so:

select * where {
  service <db://system> {
    graph <tag:stardog:api:mappingsstore:store> {
      <tag:stardog:api:mappingsstore:graphs> <tag:stardog:api:mappingsstore:record> ?vg
    }
  }
}

Jess

Hi Jess!
Thanks for the update. I’ll try it once I’ve figured out why virtual graphs stopped working for me today :slight_smile: