Search code examples
sparqlsemantic-webontologysesame

What is the recommended way for adding individuals with SPARQL UPDATE?


I know that to add an individual (instance of a class) to a triple store is with the following insert statement:

PREFIX indv:<http://someexample.com/blah>
PREFIX ont:<http://someotherexample.com/blah/ontology#>
INSERT DATA
{
indv:individual_name rdf:type ont:SomeClassName.
}

My question is: is this enough?

I am asking this because I added some individuals to an owl file using protege and I saw that the file had one more triple added:

indv:individual_name rdf:type owl:NamedIndividual.

Is it necessary to insert this triple into the triple store as well? What are the benefits for inserting this triple or are there any disadvantages?


Solution

  • My question is: is this enough?

    To simply add an instance of a class, in RDF, that is enough. In RDF, resources can be members of classes, and that's represented by a triple with the property rdf:type.

    I am asking this because I added some individuals to an owl file using protege and I saw that the file had one more triple added:

    indv:individual_name rdf:type owl:NamedIndividual.
    

    Is it necessary to insert this triple into the triple store as well? What are the benefits for inserting this triple or are there any disadvantages?

    OWL has more structure than RDF. OWL is actually a logical language based on axioms and assertions. It still uses IRIs as identifiers, and the designers made sure to support serializing OWL ontologies into RDF. So you're actually working with the serialization of an OWL ontology in RDF. In general, you may find the official document, OWL 2 Web Ontology Language Mapping to RDF Graphs, useful.

    What you're seeing in the output from Protege is actually the serialization of two OWL axioms. In OWL, you can declare an individual without specifying any classes that it's a member of. You do that with an axiom like (copying from the documentation linked above):

    Declaration( NamedIndividual( *:a ) )

    That gets translated into RDF as a triple:

    T(*:a) rdf:type owl:NamedIndividual .

    The T(*:a) notation just means that whatever the translation of *:a is, that's the subject of the triple. So the "x rdf:type owl:NamedIndividual" triple is what's actually responsible for stating that "x is an individual. That is, to declare that something is an individual, you'd just do:

    INSERT DATA { indv:individual_name rdf:type owl:NamedIndivual }
    

    So what about adding another type (as in the original SPARQL update)? In OWL, you say that "a" is an member of some class, denoted by a class expression "CE", with this axiom:

    ClassAssertion( CE a )

    That's translated into RDF as

    T(a) rdf:type T(CE) .

    The T(a) and T(CE) notation just indicates that the representation of "a" and "CE" in RDF might more more complex than just a simple IRI or blank node or literal. For instance, the class expression might be a unionOf, or an intersectionOf, etc. So, if you want to add a class assertion axiom, you'd use a SPARQL update like:

    INSERT DATA {
      indv:individual_name rdf:type ont:SomeClassName.
    }
    

    Of course, you should only do that if you've actually declared the individual as well (though you'll find that this isn't always followed in practice). So, all in all, you probably want an update like this:

    INSERT DATA {
      indv:individual_name rdf:type ont:SomeClassName, owl:NamedIndividual
    }
    

    That (i) declares the individual, and (ii) assert that the individual is a member of a particular class.