3.3 library(semweb/rdf_db): The RDF database
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog Semantic Web Library 3.0
        • Two RDF APIs
          • library(semweb/rdf_db): The RDF database
            • Query the RDF database
            • Enumerating objects
            • Modifying the RDF database
              • rdf_assert/3
              • rdf_assert/4
              • rdf_retractall/3
              • rdf_retractall/4
              • rdf_update/4
              • rdf_update/5
            • Update view, transactions and snapshots
            • Type checking predicates
            • Loading and saving to file
            • Graph manipulation
            • Literal matching and indexing
            • Predicate properties
            • Prefix Handling
            • Miscellaneous predicates
            • Memory management considerations

3.3.3 Modifying the RDF database

The predicates below modify the RDF store directly. In addition, data may be loaded using rdf_load/2 or by restoring a persistent database using rdf_attach_db/2. Modifications follow the Prolog logical update view semantics, which implies that modifications remain invisible to already running queries. Further isolation can be achieved using rdf_transaction/3.

[det]rdf_assert(+Subject, +Predicate, +Object)
Assert a new triple into the database. This is equivalent to rdf_assert/4 using Graph user. Subject and Predicate are resources. Object is either a resource or a term literal(Value). See rdf/3 for an explanation of Value for typed and language qualified literals. All arguments are subject to name-space expansion. Complete duplicates (including the same graph and‘line' and with a compatible‘lifespan') are not added to the database.
[det]rdf_assert(+Subject, +Predicate, +Object, +Graph)
As rdf_assert/3, adding the predicate to the indicated named graph.
Graph is either the name of a graph (an atom) or a term Graph:Line, where Line is an integer that denotes a line number.
[det]rdf_retractall(?Subject, ?Predicate, ?Object)
Remove all matching triples from the database. As rdf_retractall/4 using an unbound graph.
[det]rdf_retractall(?Subject, ?Predicate, ?Object, ?Graph)
As rdf_retractall/3, also matching Graph. This is particulary useful to remove all triples coming from a loaded file. See also rdf_unload/1.
[det]rdf_update(+Subject, +Predicate, +Object, ++Action)
[det]rdf_update(+Subject, +Predicate, +Object, +Graph, ++Action)
Replaces one of the three (four) fields on the matching triples depending on Action:
subject(Resource)
Changes the first field of the triple.
predicate(Resource)
Changes the second field of the triple.
object(Object)
Changes the last field of the triple to the given resource or literal(Value).
graph(Graph)
Moves the triple from its current named graph to Graph. This only works with rdf_update/5 and throws an error when used with rdf_update/4.