Inserting duplicate triples with SPARQL Update

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Inserting duplicate triples with SPARQL Update

Marie
Hello,

I am currently working with SPARQL Update queries together with owlready2 to update my ontology and I came across the following issue:
When I run an INSERT query to insert a triple, this triple might be inserted although it already exists. However, Protégé does not allow me to insert a triple twice.
I reproduced this issue with the following toy ontology:

ONTOLOGY:

<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.example.org/onto#"
     xml:base="http://www.example.org/onto"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:onto="http://www.example.org/onto#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://www.example.org/onto"/>
   


   

   


   

    <owl:ObjectProperty rdf:about="http://www.example.org/onto#OP1"/>
   


   

    <owl:ObjectProperty rdf:about="http://www.example.org/onto#OP2"/>
   


   

   


   

    <owl:Class rdf:about="http://www.example.org/onto#A"/>
   


   

   


   

    <owl:NamedIndividual rdf:about="http://www.example.org/onto#I1">
        <rdf:type rdf:resource="http://www.example.org/onto#A"/>
        <OP1 rdf:resource="http://www.example.org/onto#I2"/>
        <OP2 rdf:resource="http://www.example.org/onto#I2"/>
    </owl:NamedIndividual>
   


   

    <owl:NamedIndividual rdf:about="http://www.example.org/onto#I2">
        <rdf:type rdf:resource="http://www.example.org/onto#A"/>
    </owl:NamedIndividual>
</rdf:RDF>






UPDATE QUERY:

with ontology:
    graph.update("""
    INSERT {
        onto:I1 onto:OP1 onto:I2
    }
    WHERE {}
    """)


Querying the object property of individual I1 by running “ontology.I1.OP1” now delivers
[test.I2, test.I2]
as a result. Running the following SELECT query after the INSERT query delivers:

(rdflib.term.URIRef('http://www.example.org/onto#I2'),)
(rdflib.term.URIRef('http://www.example.org/onto#I2'),)


Is this behavior of the INSERT query intended?

Thanks in advance!

Marie
Reply | Threaded
Open this post in threaded view
|

Re: Inserting duplicate triples with SPARQL Update

Jiba
Administrator
Hello,

This behaviour is not expected... but until now, dupplicates were not verified in the quadstore.

I've just added UNIQUE constraints in the database that will now prevent dupplicates, in the development version (expect a new release soon).

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Inserting duplicate triples with SPARQL Update

Marie
Alright, thank you!