1 Reply Latest reply on Jun 25, 2018 8:14 PM by Matperry-Oracle

    Does Oracle Spatial and Graph support online consistency check?

    c7caf0e7-8688-4bae-9866-bd88f8feef8b

      Does Oracle Spatial and Graph provide a mechanism for guaranteeing consistency of the ABox of an ontology based on the stored TBox?

       

      More specifically, does it guarantee that concurrent transactions will not cause the ABox of an ontology to be inconsistent with its TBox?

       

      The only triple store I've identified that provides this mechanism, so far, is Startdog (https://www.stardog.com/docs/#_validating_constraints).

       

      Thanks for the help!

        • 1. Re: Does Oracle Spatial and Graph support online consistency check?
          Matperry-Oracle

          Hi,

           

          Oracle Spatial and Graph provides methods to check the consistency of models and entailments:
          https://docs.oracle.com/en/database/oracle/oracle-database/18/rdfrm/owl-concepts.html#GUID-7BD80B7A-0EAB-4665-A792-9091D…

           

          Consistency checking for a given update is not fully automatic in the sense of, for example, a database uniqueness constraint. However, you can easily achieve the same effect with the following flow in your application code:

          1) perform SPARQL update

          2) check consistency

          3) ROLLBACK if inconsistent or COMMIT if consistent

           

          See the script output below for an example.

           

          Thanks,
          Matt

           

          SQL> @ /home/oracle/RDF/insert_check.sql

          SQL> column s$rdfterm format a10;

          SQL> column p$rdfterm format a50;

          SQL> column o$rdfterm format a10;

          SQL> set autotrace on;

          SQL>

          SQL> conn rdfuser/rdfuser;

          Connected.

          SQL>

          SQL> set serverout on;

          SQL>

          SQL> -- procedure to validate update

          SQL> create or replace procedure validate_update

            2  as

            3    lva mdsys.rdf_longVarcharArray;

            4  begin

            5    lva := sem_apis.validate_model(sem_models('m1'));

            6    if (lva is null) then

            7      dbms_output.put_line(chr(10)||'Update is VALID');

            8    else

            9      dbms_output.put_line(chr(10)||'Update is INVALID');

          10    end if;

          11  end;

          12  /

           

          Procedure created.

           

          SQL>

          SQL> -- create application table and semantic model

          SQL> create table atab(tri sdo_rdf_triple_s);

           

          Table created.

           

          SQL> exec sem_apis.create_sem_model('m1','atab','tri');

           

          PL/SQL procedure successfully completed.

           

          SQL>

          SQL> -- use UPDATE_MODEL to perform SPARQL Update

          SQL> -- use AUTOCOMMIT=F flag to prevent automatic commit

          SQL> begin

            2    sem_apis.update_model('m1',

            3      'INSERT DATA {

            4        <urn:C1> owl:disjointWith <urn:C2> .

            5        <urn:a> rdf:type <urn:C1> . }',

            6      options=>' AUTOCOMMIT=F ');

            7  end;

            8  /

           

          PL/SQL procedure successfully completed.

           

          SQL>

          SQL> -- check model contents

          SQL> select s$rdfterm, p$rdfterm, o$rdfterm

            2  from table(sem_match(

            3  'SELECT * WHERE { ?s ?p ?o }'

            4  ,sem_models('m1')

            5  ,null,null,null,null

            6  ,' PLUS_RDFT=VC '));

           

          S$RDFTERM  P$RDFTERM                          O$RDFTERM

          ---------- -------------------------------------------------- ----------

          <urn:a>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <urn:C1>

          <urn:C1>   <http://www.w3.org/2002/07/owl#disjointWith>       <urn:C2>

           

          SQL>

          SQL> -- check consistency

          SQL> exec validate_update();

           

          Update is VALID

           

          PL/SQL procedure successfully completed.

           

          SQL>

          SQL> -- update was valid so commit

          SQL> commit;

           

          Commit complete.

           

          SQL>

          SQL> -- insert an inconsistent triple

          SQL> -- resource member of two disjoint classes

          SQL> begin

            2    sem_apis.update_model('m1',

            3      'INSERT DATA {

            4        <urn:a> rdf:type <urn:C2> . }',

            5      options=>' AUTOCOMMIT=F ');

            6  end;

            7  /

           

          PL/SQL procedure successfully completed.

           

          SQL>

          SQL> -- check contents

          SQL> select s$rdfterm, p$rdfterm, o$rdfterm

            2  from table(sem_match(

            3  'SELECT * WHERE { ?s ?p ?o }'

            4  ,sem_models('m1')

            5  ,null,null,null,null

            6  ,' PLUS_RDFT=VC '));

           

          S$RDFTERM  P$RDFTERM                          O$RDFTERM

          ---------- -------------------------------------------------- ----------

          <urn:C1>   <http://www.w3.org/2002/07/owl#disjointWith>       <urn:C2>

          <urn:a>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <urn:C1>

          <urn:a>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <urn:C2>

           

          SQL>

          SQL> -- check consistency

          SQL> exec validate_update();

           

          Update is INVALID

           

          PL/SQL procedure successfully completed.

           

          SQL>

          SQL> -- update was invalid so rollback update

          SQL> -- NOTE: concurrent users would never see these

          SQL> -- added triples because the update was never committed

          SQL> rollback;

           

          Rollback complete.

           

          SQL>

          SQL> -- check contents - invalid triples are gone

          SQL> select s$rdfterm, p$rdfterm, o$rdfterm

            2  from table(sem_match(

            3  'SELECT * WHERE { ?s ?p ?o }'

            4  ,sem_models('m1')

            5  ,null,null,null,null

            6  ,' PLUS_RDFT=VC '));

           

          S$RDFTERM  P$RDFTERM                          O$RDFTERM

          ---------- -------------------------------------------------- ----------

          <urn:C1>   <http://www.w3.org/2002/07/owl#disjointWith>       <urn:C2>

          <urn:a>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <urn:C1>