Storing separately individuals and ontology in sesame store

157 views Asked by At

I have an ontology that I imported in a sesame repository. I want to add individuals for the classes that are defined in my ontology.

Is it possible to add the individuals into another repository and not in the one that has stored the ontology? If this is possible how ca I link the individuals to the ontology and run queries on them?

Or is it a good practice to store them all together?

1

There are 1 answers

0
Jeen Broekstra On BEST ANSWER

It's possible to store your individuals and the ontology in separate repositories and then query over them together, yes. However, it's not a common way to handle things. A far simpler approach is that you put both datasets in the same Repository, but put each in a separate context or named graph. Sesame is a quad-store, which means it allows you to set a named graph identifier (in Sesame's API this is called a context identifier) on your data. This can then be used to identify subsets in your Repository. See the documentation about the Repository API for more details on how to use context programmatically. If you are working manually, through the Workbench, just make sure that when you upload your files you have an appropriate context identifier set in the corresponding form field (any URI will do, but best make it something easy to remember).

However, if you have your heart set on using separate repositories, there's two out-of-the box ways to query over more than one repository.

The first is by using the SPARQL SERVICE clause. Imagine you have two repositories, one called Instances and one called Ontology. Each Sesame repository is also a SPARQL endpoint, so can query over the combined dataset by executing, for example, the following query on the Instances repository :

  SELECT ?i ?c
  WHERE { 
         SERVICE <http://localhost:8080/openrdf-sesame/repositories/Ontology> { 
                    ?c rdfs:subClassOf :SomeClass .
         }
         ?i a ?c .
  }

A second way is by creating a Federated Repository in Sesame. A Federated Repository is a 'virtual' database that consists of a number of 'member' repositories. You can query a Federated Repository like any other repository, and under the hood it will distribute your query over the member stores and integrate the results. See the Sesame user documentation for details on how to set this up either manually via the Workbench, or programmatically.