0

I have created a template as following

declareUpdate();

var tde = require("/MarkLogic/tde.xqy");

var LocationView = xdmp.toJSON(

{

  "template":{

     "rows":[

      {

        "schemaName":"Location",

        "viewName":"Location",

        "columns":[

          {

            "name":"City",

            "scalarType":"string",

            "val":"City"

          }

        ]

      }

    ]

  }

}

);

tde.templateInsert("Location.json", LocationView);

Now is it possible to create a semantic relation using this template so that if I do semantic query i can fetch the data related to this schema from marklogic? If yes then how?

1 Answers1

0

If this view is populated only by this template, there's really no need for an explicit relation.

If, however, multiple templates populate the same view, the straightforward approach is for each template to add a sourceTemplate column with the template name as the value of the column in the row.

Multiple templates can populate the same view when you're ingesting documents with different structures and extracting and mapping the data from documents with a different structure to a normalized view.

Footnote: The semantics tag on this question makes me wonder if it's clear that views are the equivalent of a relational table. A TDE template can also project triples instead of or in addition to projecting rows into a view. The basic suggestion would be the same, but the approach would be to use a sourceTemplate predicate and the specify the template name as a literal object for the triple.

ehennum
  • 7,295
  • 13
  • 9