Search code examples
rdfontologyrdfsrdfstore

RDF: should the ontology and the statements be separate?


I am using Jena, the Java library, in order to parse my RDFS ontology as such:

model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM); 
model.read(new FileInputStream(ontologyPath), ""); 

I then add some statements and save like this:

s = model.createStatement(resource, hasName, user.getName());
model.add(s);
m.write(System.out, "RDF/XML");

The statement is then, obviously, written in the ontology file.

My question is: should it be so? Is it common practice for the ontology and triples to stay in the same file or should they be separate? Also, if they should be separate, how do I do this with Jena?


Solution

  • This is largely an application-specific question. For small, one-off, kinds of things, there's not much problem in putting property and class declarations in the same ontology as your instance data. As soon as you want to reuse a vocabulary, though, it usually makes more sense to have it separate.

    Keeping them in the same model is pretty easy in Jena; you just create one model and then do everything with it. You probably don't need an example of this. To load things in different models, it's easiest to either use OntModels and submodels, or to use union models. The relevant places to look in the documentation, at least to start, are probably: