Removing / updating BiTemporal Triples in MarkLogic 8

With the introduction of new BiTemporal features in MarkLogic8, you can track changes in two time axes: real and system. These features are also supported for triples. So you can go back in time along these two axes and perhaps see the changes. However, since triples are stored in documents, and bitporal metadata is not stored at the document level at three levels, you cannot delete or update a specific triple. In addition, you cannot use the new SPARQL update functions with temporary triples. Here is an example:

On the first day, we add the following triples, which, suppose, are always true:

<temporalTriples>
  <systemStart />
  <systemEnd />
  <validStart>2001-01-01T00:00:00Z</validStart>
  <validEnd>2999-01-01T00:00:00Z</validEnd>
  <sem:triples>
    <sem:triple>
      <sem:subject>Denver</sem:subject>
      <sem:predicate>state</sem:predicate>
      <sem:object>CO</sem:object>
    </sem:triple>
    <sem:triple>
      <sem:subject>San Francisco</sem:subject>
      <sem:predicate>state</sem:predicate>
      <sem:object>CA</sem:object>
    </sem:triple>
  </sem:triples>
</temporalTriples>

On Day 2, we add the following three, as we think the Moon lives in Denver:

<temporalTriples>
  <systemStart />
  <systemEnd />
  <validStart>{current-dateTime()}</validStart>
  <validEnd>2999-01-01T00:00:00Z</validEnd>
  <sem:triples xmlns:sem="http://marklogic.com/semantics">
    <sem:triple>
      <sem:subject>Luna</sem:subject>
      <sem:predicate>city</sem:predicate>
      <sem:object>Denver</sem:object>
    </sem:triple>
  </sem:triples>
</temporalTriples>

, 3, -, , :

<temporalTriples>
  <systemStart />
  <systemEnd />
  <validStart>{current-dateTime()}</validStart>
  <validEnd>2999-01-01T00:00:00Z</validEnd>
  <sem:triples xmlns:sem="http://marklogic.com/semantics">
    <sem:triple>
      <sem:subject>Luna</sem:subject>
      <sem:predicate>city</sem:predicate>
      <sem:object>San Francisco</sem:object>
    </sem:triple>
  </sem:triples>
</temporalTriples>

/ , - MarkLogic :

  • ( ), , <Luna> <city> <Denver>.
  • ( ), .
  • ( ), <Luna> <city> <San Francisco>.

, :

sem:sparql('SELECT *
  WHERE {
    ?s ?p ?o .
  }',
    (),
    (),
    sem:store(
      (),
      cts:and-query((
        cts:period-range-query(
          "valid",
          "ALN_CONTAINS",
          cts:period( xs:dateTime("2998-12-31T23:59:59Z") )
         ),
         cts:collection-query("temporalCollection"),
         cts:collection-query("temp/triples.xml")
     ))
   )
)

, :

  • , , , - .
  • , , , , , .

:

  • : ML8. , .
  • : . "" , timeal: document-delete. , . , , .
  • (, - ). ( ML8 SPARQL), , , , / DB,

/ , ?

+4

Source: https://habr.com/ru/post/1615491/


All Articles