15.41 SEM_APIS.CREATE_RDFVIEW_GRAPH

Format

SEM_APIS.CREATE_RDFVIEW_GRAPH(
     rdf_graph_name      IN VARCHAR2, 
     tables              IN SYS.ODCIVarchar2List, 
     prefix              IN VARCHAR2 DEFAULT NULL, 
     r2rml_table_owner   IN VARCHAR2 DEFAULT NULL, 
     r2rml_table_name    IN VARCHAR2 DEFAULT NULL, 
     schema_table_owner  IN VARCHAR2 DEFAULT NULL, 
     schema_table_name   IN VARCHAR2 DEFAULT NULL, 
     options             IN VARCHAR2 DEFAULT NULL,
     r2rml_string        IN CLOB     DEFAULT NULL,
     r2rml_string_fmt    IN VARCHAR2 DEFAULT NULL,
     network_owner       IN VARCHAR2 DEFAULT NULL,
     network_name        IN VARCHAR2 DEFAULT NULL);

Description

Creates an RDF view using direct mapping for the specified list of tables or views or using R2RML mapping.

Parameters

rdf_graph_name

Name of the RDF view to be created.

tables

List of tables or views that are the sources of relational data for the RDF view to be created using direct mapping. This parameter must be null if you want to use R2RML mapping.

prefix

Base prefix to be added at the beginning of the URIs in the RDF view.

r2rml_table_owner

For R2ML mapping, this parameter is required and specifies the name of the schema that owns the staging table that holds the R2RML mapping (in N-triple format) to be used for creating the RDF view.

For direct mapping, this parameter is optional and specifies the name of the schema that owns the staging table into which the R2RML mapping (in N-triple format) generated from the direct mapping will be stored.

r2rml_table_name

For R2ML mapping, this parameter is required and specifies the name of the staging table that holds the R2RML mapping (in N-triple format) to be used for creating the RDF view.

For direct mapping, this parameter is optional and specifies the name of the staging table into which the R2RML mapping (in N-triple format) generated from the direct mapping will be stored.

schema_table_owner

Name of the schema that owns the staging table where the RDF schema generated for the RDF view will be stored.

schema_table_name

Name of the staging table where the RDF schema generated for the RDF view will be stored.

options

For direct mapping, you can optionally specify any combination (including none) of the following:

  • CONFORMANCE=T suppresses some of the information that would otherwise get included by default, including use of database constraint names and schema-qualified table or view names for constructing RDF predicate names.

  • GENERATE_ONLY=T only generates the R2RML mapping for the specified tables and stores it in the specified r2rml_table_name, but the underlying RDF view graph is not created. If you specify this option, the r2rml_table_name parameter must not be null.

  • KEY_BASED_REF_PROPERTY=T uses the foreign key column names to construct the RDF predicate name. If this option is not specified, then the database constraint name is used for constructing the RDF predicate name.

    For direct mapping, RDF predicate names are derived from the corresponding database names; therefore, preserving the name for the foreign key constraint is the default behavior.

    For an example that uses KEY_BASED_REF_PROPERTY=T , see Example 10-1 in Creating an RDF View with Direct Mapping.

  • SCALAR_COLUMNS_ONLY=T generates the R2RML mapping for only the scalar columns in the specified tables or views. Other non-scalar columns in the tables or views are ignored. Without this option, if you attempt to create a direct mapping on a table with user-defined types or LOB columns, an error is raised.

r2rml_string

An R2RML mapping string in Turtle or N-Triple format to be used for creating the RDF view.

r2rml_string_fmt

The format of the R2RML mapping string specified in r2rml_string. Possible values are TURTLE and N-TRIPLE.

network_owner

Owner of the RDF network. (See Table 1-2.)

network_name

Name of the RDF network. (See Table 1-2.)

Usage Notes

You must grant the SELECT and INSERT privileges on r2rml_table_name and schema_table_name to the network owner.

For more information about RDF views, see RDF Views: Relational Data as RDF.

For information about RDF network types and options, see RDF Networks.

Examples

The following example creates an RDF view using direct mapping for tables EMP and DEPT. The prefix used for the URIs is http://empdb/.

BEGIN
  sem_apis.create_rdfview_graph(
    rdf_graph_name => 'empdb_model_direct',
    tables => sem_models('EMP', 'DEPT'),
    prefix => 'http://empdb/',
    network_owner=>'RDFUSER',
    network_name=>'NET1'
  );
END;
/

The following example creates an RDF view using R2RML mapping as specified by the RDF triples in the staging table SCOTT.R2RTAB.

BEGIN
  sem_apis.create_rdfview_graph(
    rdf_graph_name => 'empdb_model_R2RML',
    tables => NULL,
    r2rml_table_owner => 'SCOTT',
    r2rml_table_name => 'R2RTAB',
    network_owner=>'RDFUSER',
    network_name=>'NET1'
  );
END;
/

The following example creates an RDF view using an R2RML mapping specified directly as a string.

DECLARE
  r2rmlStr CLOB;
BEGIN

  r2rmlStr := 
   '@prefix rr: <http://www.w3.org/ns/r2rml#>. '||
   '@prefix xsd: <http://www.w3.org/2001/XMLSchema#>. '||
   '@prefix ex: <http://example.com/ns#>. '||'
    
    ex:TriplesMap_Emp
        rr:logicalTable [ rr:tableName "EMP" ];
        rr:subjectMap [
            rr:template "http://data.example.com/employee/{EMPNO}";
            rr:class ex:Employee;
        ];
        rr:predicateObjectMap [
            rr:predicate ex:empNum;
            rr:objectMap [ rr:column "EMPNO" ; rr:datatype xsd:integer ];
        ];
        rr:predicateObjectMap [
            rr:predicate ex:empName;
            rr:objectMap [ rr:column "ENAME" ];
        ];
        rr:predicateObjectMap [
            rr:predicate ex:jobType;
            rr:objectMap [ rr:column "JOB" ];
        ];
        rr:predicateObjectMap [
            rr:predicate ex:worksForDeptNum;
            rr:objectMap [ rr:column "DEPTNO" ; rr:dataType xsd:integer ];
        ].';

  sem_apis.create_rdfview_graph(
    rdf_graph_name => 'empdb_model_R2RML',
    tables => NULL,
    r2rml_string => r2rmlStr,
    r2rml_string_fmt => 'TURTLE',
    network_owner=>'RDFUSER',
    network_name=>'NET1'
  );

END;
/

The following example creates an RDF view using direct mapping as specified by the RDF triples in the tables EMP and DEPT in the schema-private network owned by RDFUSER. It also selects information about employees who work at the Boston location.

BEGIN
  sem_apis.create_rdfview_graph(
  rdf_graph_name => 'empdb_model',
  tables => SYS.ODCIVarchar2List('EMP', 'DEPT'),
  prefix => 'http://empdb/',
  options => 'KEY_BASED_REF_PROPERTY=T',
  network_owner=>'RDFUSER',
  network_name=>'NET1'
  );
END;
/

SELECT e.empno FROM emp e, dept d WHERE e.deptno = d.deptno AND d.loc = 'Boston';

SELECT emp
FROM TABLE(SEM_MATCH('{?emp emp:ref-DEPTNO ?dept . ?dept dept:LOC "Boston"}',SEM_Models('empdb_model'),NULL,SEM_ALIASES(
SEM_ALIAS('dept','http://empdb/RDFUSER.DEPT#'),SEM_ALIAS('emp','http://empdb/RDFUSER.EMP#')),null,null,null,null,null,'RDF_USER','NET1'));