The Jena Layer Cake
CraigTrim 110000G799 Visits (6364)
Graph layer is the base layer in Jena.
The Graph layer is very granular and is a very minimal implementation of the RDF specification. There are less methods available, and certain techniques such as reification, are not possible.
By separating the Graph layer from the Model layer, the Jena development team has made it very easy to extend the base Jena functionality. So, if you want to extend the Jena API, or use the Jena API in your own product, then you extend the Graph interfaces. And once you do that, you'll end up with something resembling the Model layer. The Model layer is simply the official Jena extension of the Graph layer.
Now if you're a developer, and you're working with the Jena, using either in-memory datasets or a TDB-backed dataset, you'll typically be working at the Model layer. There's really no reason to work with the Graph layer on a day-to-day basis. No benefits in terms of performance or convenience.
Creating a triple in the Graph layer:
This code creates an instance of a Triple object, populated with a subject, predicate and object. Each of these latter three are instances of the Node object. The triple is then added to the RDF graph.
Creating a triple in the Model layer:
So what's different about these two techniques? At a glance, there's roughly the same amount of code, and neither the Model nor the Graph layer seem to offer any more or any less in terms of either complexity or simplicity. However, the Model layer has extended the core functionality in the Graph layer in such a way, that by allowing developers to work with objects of type "Resource" or "Property" or "Statement", instead of "Node" or "Triple", there are simply more methods available in the Model layer objects that are convenient.
The third and final layer in the Jena API is the OntModel (Ontology Model) layer. This gives you inference capabilities. That is, the ability to work with triples that are implied, in addition to the triples that have been explicitly defined. So, if you have a predicate in your RDF model, and it's defined as transitive, given these explicit relationships:
The OntModel would be one way to arrive at this deduction. And it would do that by relying on an automated reasoner responsible for finding implicit triples from explicit information.
References and Resources: