VOS.VirtSPARUL

  • Topic
  • Discussion
  • VOS.VirtSPARUL(1.1) -- DAVWikiAdmin? , 2017-06-13 05:42:16 Edit WebDAV System Administrator 2017-06-13 05:42:16

    SPARUL

    SPARUL is an Update Language For RDF Graphs.

    Since version 5.0, Virtuoso has supported the SPARQL/Update (SPARUL) extension of SPARQL. This is sufficient for most routine data manipulation operations.

    If SPARQL_UPDATE role is granted to SPARQL user, then data manipulation statements may be executed via the SPARQL Web service endpoint; if SPARQL_UPDATE role is not granted, users are limited to data querying statements.

    Related Functions

    Two functions allow the user to alter RDF storage by inserting or deleting all triples listed in some vector.

    Both functions receive an IRI of a graph that should be altered and a vector of triples that should be added or removed. The graph IRI can be either IRI ID or a string.

    The return values of these functions are not defined and should not be used by applications.


    create function DB.DBA.RDF_INSERT_TRIPLES (in graph_iri any, in triples any);
    create function DB.DBA.RDF_DELETE_TRIPLES (in graph_iri any, in triples any);
    

    Simple operations may be faster if written as low-level SQL code instead of using SPARUL. For instance, the use of SPARQL DELETE is redundant when the application can delete from RDF_QUAD by using simple filters like:


    delete from DB.DBA.RDF_QUAD
    where G = DB.DBA.RDF_MAKE_IID_OF_QNAME (
        'http://local.virt/DAV/sparql_demo/data/data-xml/source-simple2/source-data-01.rdf' );
    

    On the other hand, simple filters do not work when search criteria refer to triples that are affected by the modification.

    Consider a function that deletes all triples whose subjects are nodes of type 'http://xmlns.com/foaf/0.1/Person'. Type information is stored in triples that will be deleted, so the simplest function is something like this:


    create procedure DELETE_PERSONAL_DATA (in foaf_graph varchar)
    {
      declare pdata_dict, pdata_array any;
    -- Step 1: select everything that should be deleted
      pdata_dict := ((
          sparql construct { ?s ?p ?o }
          where { graph ?:foaf_graph {
                  ?s ?p ?o . ?s rdf:type <http://xmlns.com/foaf/0.1/Person>
                } }
          ));
    -- Step 2: delete all found triples
      pdata_array := dict_list_keys (pdata_dict, 1);
      RDF_DELETE_TRIPLES (foaf_graph, pdata_array);
    };
    
    DELETE_PERSONAL_DATA (
      'http://local.virt/DAV/sparql_demo/data/data-xml/source-simple2/source-data-01.rdf' );
    

    Since Virtuoso 5.0, applications may use SPARUL to do the same in a more convenient way:


    create procedure DELETE_PERSONAL_DATA (in foaf_graph varchar)
    {
      sparql delete { ?s ?p ?o }
          where { graph ?:foaf_graph {
                  ?s ?p ?o . ?s rdf:type <http://xmlns.com/foaf/0.1/Person>
               } }
    };
    

    Virtuoso's SPARUL Implementation

    References

    Specs

    FAQs

    Presentations

    Tutorials

    CategoryGlossary CategorySPARQL CategoryRDF CategoryVOS CategoryDocumentation