PK
.Aoa, mimetypeapplication/epub+zipPK .A iTunesMetadata.plist]
The SEM_APIS package contains subprograms (functions and procedures) for working with the Resource Description Framework (RDF) and Web Ontology Language (OWL) in an Oracle database. To use the subprograms in this chapter, you must understand the conceptual and usage information in Chapter 1, "Oracle Database Semantic Technologies Overview" and Chapter 2, "OWL Concepts".
This chapter provides reference information about the subprograms, listed in alphabetical order.
Format
SEM_APIS.ADD_DATATYPE_INDEX(
datatype IN VARCHAR2,
tablespace_name IN VARCHAR2 default NULL,
parallel IN PLS_INTEGER default NULL,
online IN BOOLEAN default FALSE,
options IN VARCHAR2 default NULL);
Description
Adds a data type index for the specified data type to the semantic network.
Parameters
URI of the data type to index.
Destination tablespace for the index.
Degree of parallelism to use when building the index.
TRUE
allows DML operations affecting the index during creation of the index; FALSE
(the default) does not allow DML operations affecting the index during creation of the index.
String specifying options for index creation using the form OPTION_NAME=option_value. Supported options are SRID
, TOLERANCE
, and DIMENSIONS
, which are all associated with spatial index creation (see Section 1.6.6.2, "Indexing Spatial Data"). The option name keywords are case sensitive and must be specified in uppercase.
Usage Notes
You must have DBA privileges to call this procedure.
For more information about data type indexing, see Section 1.9.
For information about creating a data type index on RDF spatial data, see Section 1.6.6.2.
Examples
The following example creates an index on xsd:string
typed literals and plain literals in the MY_TBS tablespace.
EXECUTE SEM_APIS.ADD_DATATYPE_INDEX('http://www.w3.org/2001/XMLSchema#string', tablespace_name=>'MY_TBS', parallel=>4);
Format
SEM_APIS.ADD_SEM_INDEX(
index_code IN VARCHAR2);
Description
Creates a semantic network index that results in creation of a nonunique B-tree index in UNUSABLE status for each of the existing models and entailments of the semantic network.
Parameters
Index code string.
Usage Notes
You must have DBA privileges to call this procedure.
For an explanation of semantic network indexes, see Section 1.8.
Examples
The following example creates a semantic network index with the index code string pcsm
on the models and entailments of the semantic network.
EXECUTE SEM_APIS.ADD_SEM_INDEX('pscm');
Format
SEM_APIS.ALTER_DATATYPE_INDEX(
datatype IN VARCHAR2,
command IN VARCHAR2,
tablespace_name IN VARCHAR2 default NULL,
parallel IN PLS_INTEGER default NULL,
online IN BOOLEAN default FALSE);
Description
Alters a data type index.
Parameters
URI of the data type to index.
String specifying the command to be performed: REBUILD
to rebuild the data type index, or UNUSABLE
to marks the data type index as unusable. The value for this parameter is not case-sensitive.
Destination tablespace for the index.
Degree of parallelism to use when rebuilding the index.
TRUE
allows DML operations affecting the index during rebuilding of the index; FALSE
(the default) does not allow DML operations affecting the index during rebuilding of the index.
Usage Notes
You must have DBA privileges to call this procedure.
For an explanation of data type indexes, see Section 1.9.
Examples
The following example rebuilds the index on xsd:string
typed literals and plain literals in the MY_TBS tablespace.
EXECUTE SEM_APIS.ALTER_DATATYPE_INDEX('http://www.w3.org/2001/XMLSchema#string', command=>'REBUILD', tablespace_name=>'MY_TBS', parallel=>4);
Format
SEM_APIS.ALTER_ENTAILMENT(
entailment_name IN VARCHAR2,
command IN VARCHAR2,
tablespace_name IN VARCHAR2,
parallel IN NUMBER(38) DEFAULT NULL);
Description
Alters an entailment (rules index). Currently, the only action supported is to move the entailment to a specified tablespace.
Parameters
Name of the entailment.
Must be the string MOVE
.
Name of the destination tablespace.
Degree of parallelism to be associated with the operation. For more information about parallel execution, see Oracle Database VLDB and Partitioning Guide.
Usage Notes
For an explanation of entailments, see Section 1.3.7.
Examples
The following example moves the entailment named rdfs_rix_family
to the tablespace named my_tbs
.
EEXECUTE SEM_APIS.ALTER_ENTAILMENT('rdfs_rix_family', 'MOVE', 'my_tbs');
Format
SEM_APIS.ALTER_MODEL(
model_name IN VARCHAR2,
command IN VARCHAR2,
tablespace_name IN VARCHAR2,
parallel IN NUMBER(38) DEFAULT NULL);
Description
Alters a model. Currently, the only action supported is to move the model to a specified tablespace.
Parameters
Name of the model.
Must be the string MOVE
.
Name of the destination tablespace.
Degree of parallelism to be associated with the operation. For more information about parallel execution, see Oracle Database VLDB and Partitioning Guide.
Usage Notes
For an explanation of models, see Section 1.2, "Semantic Data Modeling" and Section 1.3, "Semantic Data in the Database".
This procedure is not supported on version-enabled RDF models, as explained in Section 6.5, "Special Considerations When Using Workspace Manager Support for RDF Data".
Examples
The following example moves the model named family
to the tablespace named my_tbs
.
EEXECUTE SEM_APIS.ALTER_MODEL('family', 'MOVE', 'my_tbs');
Format
SEM_APIS.ALTER_SEM_INDEX_ON_ENTAILMENT(
entailment_name IN VARCHAR2,
index_code IN VARCHAR2,
command IN VARCHAR2,
tablespace_name IN VARCHAR2 DEFAULT NULL,
use_compression IN BOOLEAN DEFAULT NULL,
parallel IN NUMBER(38) DEFAULT NULL,
online IN BOOLEAN DEFAULT FALSE);
Description
Alters a semantic network index on an entailment.
Parameters
Name of the entailment.
Index code string.
String value containing one of the following commands: REBUILD
rebuilds the semantic network index on the entailment, or UNUSABLE
marks as unusable the semantic network index on the entailment. The value for this parameter is not case-sensitive.
Name of the destination tablespace for the rebuild operation.
Specifies whether compression should be used when rebuilding the index.
Degree of parallelism to be associated with the operation. For more information about parallel execution, see Oracle Database VLDB and Partitioning Guide.
TRUE
allows DML operations affecting the index during the rebuilding of the index; FALSE
(the default) does not allow DML operations affecting the index during the rebuilding of the index.
Usage Notes
For an explanation of semantic network indexes, see Section 1.8.
Examples
The following example rebuilds (and makes usable if it is unusable) the semantic network index on the entailment named rdfs_rix_family
.
EXECUTE SEM_APIS.ALTER_SEM_INDEX_ON_ENTAILMENT('rdfs_rix_family', 'pscm', 'rebuild');
Format
SEM_APIS.ALTER_SEM_INDEX_ON_MODEL(
model_name IN VARCHAR2,
index_code IN VARCHAR2,
command IN VARCHAR2,
tablespace_name IN VARCHAR2 DEFAULT NULL,
use_compression IN BOOLEAN DEFAULT NULL,
parallel IN NUMBER(38) DEFAULT NULL,
online IN BOOLEAN DEFAULT FALSE);
Description
Alters a semantic network index on a model.
Parameters
Name of the model.
Index code string.
String value containing one of the following commands: REBUILD
rebuilds the semantic network index on the model, or UNUSABLE
marks as unusable the semantic network index on the model. The value for this parameter is not case-sensitive.
Name of the destination tablespace for the rebuild operation.
Specifies whether compression should be used when rebuilding the index.
Degree of parallelism to be associated with the operation. For more information about parallel execution, see Oracle Database VLDB and Partitioning Guide.
TRUE
allows DML operations affecting the index during the rebuilding of the index; FALSE
(the default) does not allow DML operations affecting the index during the rebuilding of the index.
Usage Notes
For an explanation of semantic network indexes, see Section 1.8.
Examples
The following example rebuilds (and makes usable if it is unusable) the semantic network index on the model named family
.
EXECUTE SEM_APIS.ALTER_SEM_INDEX_ON_MODEL('family', 'pscm', 'rebuild');
Format
SEM_APIS.ANALYZE_ENTAILMENT(
entailment_name IN VARCHAR2,
estimate_percent IN NUMBER DEFAULT to_estimate_percent_type (get_param('ESTIMATE_PERCENT')),
method_opt IN VARCHAR2 DEFAULT get_param('METHOD_OPT'),
degree IN NUMBER DEFAULT to_degree_type(get_param('DEGREE')),
cascade IN BOOLEAN DEFAULT to_cascade_type(get_param('CASCADE')),
no_invalidate IN BOOLEAN DEFAULT to_no_invalidate_type (get_param('NO_INVALIDATE')),
force IN BOOLEAN DEFAULT FALSE);
Description
Collects statistics for a specified entailment (rules index).
Parameters
Name of the entailment.
Percentage of rows to estimate in the internal table partition containing information about the entailment (NULL
means compute). The valid range is [0.000001,100]. Use the constant DBMS_STATS
.AUTO_SAMPLE_SIZE
to have Oracle determine the appropriate sample size for good statistics. This is the usual default.
Accepts either of the following options, or both in combination, for the internal table partition containing information about the entailment:
FOR ALL [INDEXED | HIDDEN] COLUMNS
[size_clause]
FOR COLUMNS
[size clause] column|attribute [size_clause] [,column|attribute [size_clause]...]
size_clause
is defined as size_clause := SIZE {integer | REPEAT | AUTO | SKEWONLY}
column
is defined as column := column_name | (extension)
- integer
: Number of histogram buckets. Must be in the range [1,254].- REPEAT
: Collects histograms only on the columns that already have histograms.- AUTO
: Oracle determines the columns to collect histograms based on data distribution and the workload of the columns.- SKEWONLY
: Oracle determines the columns to collect histograms based on the data distribution of the columns.column_name
: name of a columnextension:
Can be either a column group in the format of (column_name
, column_name
[, ...]) or an expression.
The usual default is FOR ALL COLUMNS SIZE AUTO
.
Degree of parallelism for the internal table partition containing information about the entailment. The usual default for degree
is NULL
, which means use the table default value specified by the DEGREE
clause in the CREATE TABLE
or ALTER TABLE
statement. Use the constant DBMS_STATS.DEFAULT_DEGREE
to specify the default value based on the initialization parameters. The AUTO_DEGREE
value determines the degree of parallelism automatically. This is either 1 (serial execution) or DEFAULT_DEGREE
(the system default value based on number of CPUs and initialization parameters) according to size of the object.
Gathers statistics on the indexes for the internal table partition containing information about the entailment. Use the constant DBMS_STATS.AUTO_CASCADE
to have Oracle determine whether index statistics are to be collected or not. This is the usual default.
Does not invalidate the dependent cursors if set to TRUE
. The procedure invalidates the dependent cursors immediately if set to FALSE
. Use DBMS_STATS
.AUTO_INVALIDATE
. to have Oracle decide when to invalidate dependent cursors. This is the usual default.
TRUE
gathers statistics even if the entailment is locked; FALSE
(the default) does not gather statistics if the entailment is locked.
Usage Notes
Index statistics collection can be parellelized except for cluster, domain, and join indexes.
This procedure internally calls the DBMS_STATS.GATHER_TABLE_STATS procedure, which collects statistics for the internal table partition that contains information about the entailment. The DBMS_STATS.GATHER_TABLE_STATS procedure is documented in Oracle Database PL/SQL Packages and Types Reference.
For information about entailments, see Section 1.3.7.
Examples
The following example collects statistics for the entailment named rdfs_rix_family
.
EXECUTE SEM_APIS.ANALYZE_ENTAILMENT('rdfs_rix_family');
Format
SEM_APIS.ANALYZE_MODEL(
model_name IN VARCHAR2,
estimate_percent IN NUMBER DEFAULT to_estimate_percent_type (get_param('ESTIMATE_PERCENT')),
method_opt IN VARCHAR2 DEFAULT get_param('METHOD_OPT'),
degree IN NUMBER DEFAULT to_degree_type(get_param('DEGREE')),
cascade IN BOOLEAN DEFAULT to_cascade_type(get_param('CASCADE')),
no_invalidate IN BOOLEAN DEFAULT to_no_invalidate_type (get_param('NO_INVALIDATE')),
force IN BOOLEAN DEFAULT FALSE);
Description
Collects optimizer statistics for a specified model.
Parameters
Name of the model.
Percentage of rows to estimate in the internal table partition containing information about the model (NULL
means compute). The valid range is [0.000001,100]. Use the constant DBMS_STATS
.AUTO_SAMPLE_SIZE
to have Oracle determine the appropriate sample size for good statistics. This is the usual default.
Accepts either of the following options, or both in combination, for the internal table partition containing information about the model:
FOR ALL [INDEXED | HIDDEN] COLUMNS
[size_clause]
FOR COLUMNS
[size clause] column|attribute [size_clause] [,column|attribute [size_clause]...]
size_clause
is defined as size_clause := SIZE {integer | REPEAT | AUTO | SKEWONLY}
column
is defined as column := column_name | (extension)
- integer
: Number of histogram buckets. Must be in the range [1,254].- REPEAT
: Collects histograms only on the columns that already have histograms.- AUTO
: Oracle determines the columns to collect histograms based on data distribution and the workload of the columns.- SKEWONLY
: Oracle determines the columns to collect histograms based on the data distribution of the columns.column_name
: name of a columnextension:
Can be either a column group in the format of (column_name
, column_name
[, ...]) or an expression.
The usual default is FOR ALL COLUMNS SIZE AUTO
.
Degree of parallelism for the internal table partition containing information about the model. The usual default for degree
is NULL
, which means use the table default value specified by the DEGREE
clause in the CREATE TABLE
or ALTER TABLE
statement. Use the constant DBMS_STATS.DEFAULT_DEGREE
to specify the default value based on the initialization parameters. The AUTO_DEGREE
value determines the degree of parallelism automatically. This is either 1 (serial execution) or DEFAULT_DEGREE
(the system default value based on number of CPUs and initialization parameters) according to size of the object.
Gathers statistics on the indexes for the internal table partition containing information about the model. Use the constant DBMS_STATS.AUTO_CASCADE
to have Oracle determine whether index statistics are to be collected or not. This is the usual default.
Does not invalidate the dependent cursors if set to TRUE
. The procedure invalidates the dependent cursors immediately if set to FALSE
. Use DBMS_STATS
.AUTO_INVALIDATE
. to have Oracle decide when to invalidate dependent cursors. This is the usual default.
TRUE
gathers statistics even if the model is locked; FALSE
(the default) does not gather statistics if the model is locked.
Usage Notes
Index statistics collection can be parellelized except for cluster, domain, and join indexes.
This procedure internally calls the DBMS_STATS.GATHER_TABLE_STATS procedure, which collects optimizer statistics for the internal table partition that contains information about the model. The DBMS_STATS.GATHER_TABLE_STATS procedure is documented in Oracle Database PL/SQL Packages and Types Reference.
Examples
The following example collects statistics for the semantic model named family
.
EXECUTE SEM_APIS.ANALYZE_MODEL('family');
Format
SEM_APIS.BULK_LOAD_FROM_STAGING_TABLE(
model_name IN VARCHAR2,
table_owner IN VARCHAR2,
table_name IN VARCHAR2,
flags IN VARCHAR2 DEFAULT NULL,
debug IN INTEGER DEFAULT NULL,
start_comment IN VARCHAR2 DEFAULT NULL,
end_comment IN VARCHAR2 DEFAULT NULL);
Description
Loads semantic data from a staging table.
Parameters
Name of the model.
Name of the schema that owns the staging table that holds semantic data to be loaded.
Name of the staging table that holds semantic data to be loaded.
An optional quoted string with one or more of the following keyword specifications:
DEL_BATCH_DUPS=USE_INSERT
allows the use of an insertion-based strategy for duplicate elimination that may lead to faster processing if the input data contains many duplicates.
MBV_METHOD=SHADOW
allows the use of a different value loading strategy that may lead to faster processing for large loads.
PARALLEL_CREATE_INDEX
allows internal indexes to be created in parallel, which may improve the performance of the bulk load processing.
PARALLEL=<
integer
>
allows much of the processing used during bulk load to be done in parallel using the specified degree of parallelism to be associated with the operation.
PARSE
allows parsing of triples retrieved from the staging table (also parses triples containing graph names).
<task>
_JOIN_HINT=
<join_type>
, where <task> can be any of the following internal tasks performed during bulk load: IZC
(is zero collisions), MBV
(merge batch values), or MBT
(merge batch triples, used when adding triples to a non-empty model), and where <join_type> can be USE_NL
and USE_HASH
.
(Reserved for future use)
Optional comment about the start of the load operation.
Optional comment about the end of the load operation.
Usage Notes
You must first load semantic data into a staging table before calling this procedure. See Section 1.7.1 for more information.
Using BULK_LOAD_FROM_STAGING_TABLE with Fine Grained Access Control (VPD and OLS)
When fine-grained access control (explained in Chapter 5) is enabled for a specific model using VPD or for the entire network using OLS, only a user with FULL access privileges to the associated policy may perform the bulk load operation. Full access privileges to a VPD policy are granted by setting the context attribute defined by the package constant sem_rdfsa.VPD_FULL_ACCESS
to 1 for the namespace associated with the VPD policy (see Section 5.1.1). When OLS is enabled, full access privileges to the OLS policy are granted using the SA_USER_ADMIN.SET_USER_PRIVS procedure.
The data loaded into a model with VPD enabled is immediately available for access and does not need any maintenance operations. However, when the OLS is used, the label column in the tables storing the RDF triples must be maintained. By default, with OLS enabled, the label column in the tables storing the RDF triples is set to null. If you have FULL access, you can reset the labels for the newly inserted triples as well as any resources introduced by the new batch of triples by using appropriate subprograms (SEM_RDFSA.SET_RESOURCE_LABEL and SEM_RDFSA.SET_PREDICATE_LABEL).
Optionally, you can define a numeric column named RDF$STC_CTXT1 in the staging table and the application table, to assign the sensitivity label of the triple before the data is loaded into the desired model. Such labels are automatically applied to the corresponding triples stored in the MDSYS.RDF_LINK$ table. The labels for the newly introduced resources may still have to be applied separately before or after the load, and the system does not validate the labels assigned during bulk load operation.
The RDF$STC_CTXT1 column in the application table has no significance, and it may be dropped after the bulk load operation.
Examples
The following example loads semantic data stored in the staging table named STAGE_TABLE in schema SCOTT into the semantic model named family
. The example includes some join hints.
EXECUTE SEM_APIS.BULK_LOAD_FROM_STAGING_TABLE('family', 'scott', 'stage_table', flags => 'IZC_JOIN_HINT=USE_HASH MBV_JOIN_HINT=USE_HASH');
Format
SEM_APIS.CLEANUP_FAILED(
rdf_object_type IN VARCHAR2,
rdf_object_name IN VARCHAR2);
Description
Drops (deletes) a specified rulebase or entailment if it is in a failed state.
Parameters
Type of the RDF object: RULEBASE
for a rulebase or RULES_INDEX
for an entailment (rules index).
Name of the RDF object of type rdf_object_type
.
Usage Notes
This procedure checks to see if the specified RDF object is in a failed state; and if the object is in a failed state, the procedure deletes the object.
A rulebase or entailment is in a failed state if a system failure occurred during the creation of that object. You can check if a rulebase or entailment is in a failed state by checking to see if the value of the STATUS column is FAILED
in the SDO_RULEBASE_INFO view (described in Section 1.3.6) or the SDO_RULES_INDEX_INFO view (described in Section 1.3.7), respectively.
If the rulebase or entailment is not in a failed state, this procedure performs no action and returns a successful status.
An exception is generated if the RDF object is currently being used.
Examples
The following example deletes the rulebase named family_rb
if (and only if) that rulebase is in a failed state.
EXECUTE SEM_APIS.CLEANUP_FAILED('RULEBASE', 'family_rb');
Format
SEM_APIS.COMPOSE_RDF_TERM(
value_name IN VARCHAR2,
value_type IN VARCHAR2,
literal_type IN VARCHAR2,
language_type IN VARCHAR2
) RETURN VARCHAR2;
or
SEM_APIS.COMPOSE_RDF_TERM(
value_name IN VARCHAR2,
value_type IN VARCHAR2,
literal_type IN VARCHAR2,
language_type IN VARCHAR2,
long_value IN CLOB,
options IN VARCHAR2 DEFAULT NULL,
) RETURN CLOB;
Description
Creates and returns an RDF term using the specified parameters.
Parameters
Value name. Must match a value in the VALUE_NAME column in the MDSYS.RDF_VALUE$ table (described in Section 1.3.2) or in the var attribute returned from SEM_MATCH table function.
The type of text information. Must match a value in the VALUE_TYPE column in the MDSYS.RDF_VALUE$ table (described in Section 1.3.2) or in the var$RDFVTYP attribute returned from SEM_MATCH table function.
For typed literals, the type information; otherwise, null. Must either be a null value or match a value in the LITERAL_TYPE column in the MDSYS.RDF_VALUE$ table (described in Section 1.3.2) or in the var$RDFLTYP attribute returned from SEM_MATCH table function.
Language tag. Must match a value in the LANGUAGE_TYPE column in the MDSYS.RDF_VALUE$ table (described in Section 1.3.2) or in the var$RDFLANG attribute returned from SEM_MATCH table function.
The character string if the length of the lexical value is greater than 4000 bytes. Must match a value in the LONG_VALUE column in the MDSYS.RDF_VALUE$ table (described in Section 1.3.2) or in the var$RDFCLOB attribute returned from SEM_MATCH table function.
(Reserved for future use.)
Usage Notes
If you specify an inconsistent combination of values for the parameters, this function returns a null value. If a null value is returned but you believe that the values for the parameters are appropriate (reflecting columns from the same row in the MDSYS.RDF_VALUE$ table or from a SEM_MATCH query for the same variable), contact Oracle Support.
Examples
The following example returns, for each member of the family whose height is known, the RDF term for the height and also just the value portion of the height.
SELECT x, SEM_APIS.COMPOSE_RDF_TERM(h, h$RDFVTYP, h$RDFLTYP, h$RDFLANG) h_rdf_term, h FROM TABLE(SEM_MATCH( '{?x :height ?h}', SEM_Models('family'), null, SEM_ALIASES(SEM_ALIAS('','http://www.example.org/family/')), null)) ORDER BY x; X -------------------------------------------------------------------------------- H_RDF_TERM -------------------------------------------------------------------------------- H -------------------------------------------------------------------------------- http://www.example.org/family/Cathy "5.8"^^<http://www.w3.org/2001/XMLSchema#decimal> 5.8 http://www.example.org/family/Cindy "6"^^<http://www.w3.org/2001/XMLSchema#decimal> 6 http://www.example.org/family/Jack "6"^^<http://www.w3.org/2001/XMLSchema#decimal> 6 http://www.example.org/family/Tom "5.75"^^<http://www.w3.org/2001/XMLSchema#decimal> 5.75 4 rows selected.
The following example returns the RDF terms for a few of the values stored in the MDSYS.RDF_VALUE$ table.
SELECT SEM_APIS.COMPOSE_RDF_TERM(value_name, value_type, literal_type, language_type) FROM MDSYS.RDF_VALUE$ WHERE ROWNUM < 5; SEM_APIS.COMPOSE_RDF_TERM(VALUE_NAME,VALUE_TYPE,LITERAL_TYPE,LANGUAGE_TYPE) -------------------------------------------------------------------------------- <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property>
Format
SEM_APIS.CREATE_ENTAILMENT(
entailment_name_in IN VARCHAR2,
models_in IN SEM_MODELS,
rulebases_in IN SEM_RULEBASES,
passes IN NUMBER DEFAULT SEM_APIS.REACH_CLOSURE,
inf_components_in IN VARCHAR2 DEFAULT NULL,
options IN VARCHAR2 DEFAULT NULL,
delta_in IN SEM_MODELS DEFAULT NULL,
label_gen IN RDFSA_LABELGEN DEFAULT NULL,
include_named_g IN SEM_GRAPHS DEFAULT NULL,
include_default_g IN SEM_MODELS DEFAULT NULL,
include_all_g IN SEM_MODELS DEFAULT NULL,
inf_ng_name IN VARCHAR2 DEFAULT NULL);
Description
Creates an entailment (rules index) that can be used to perform OWL or RDFS inferencing, and optionally use user-defined rules.
Parameters
Name of the entailment to be created.
One or more model names. Its data type is SEM_MODELS, which has the following definition: TABLE OF VARCHAR2(25)
One or more rulebase names. Its data type is SEM_RULEBASES, which has the following definition: TABLE OF VARCHAR2(25)
. Rules and rulebases are explained in Section 1.3.6.
The number of rounds that the inference engine should run. The default value is SEM_APIS.REACH_CLOSURE
, which means the inference engine will run till a closure is reached. If the number of rounds specified is less than the number of actual rounds needed to reach a closure, the status of the entailment will then be set to INCOMPLETE
.
A comma-delimited string of keywords representing inference components, for performing selective or component-based inferencing. If this parameter is null, the default set of inference components is used. See the Usage Notes for more information about inference components.
A comma-delimited string of options to control the inference process by overriding the default inference behavior. To enable an option, specify option-name
=T
; to disable an option, you can specify option-name
=F
(the default). The available option-name values are COL_COMPRESS
, DISTANCE,DOP
, ENTAIL_ANYWAY
, HASH_PART
, INC
, LOCAL_NG_INF
, OPT_SAMEAS
, RAW8
, PROOF
, and USER_RULES
. See the Usage Notes for explanations of each value.
If incremental inference is in effect, specifies one or more models on which to perform incremental inference. Its data type is SEM_MODELS, which has the following definition: TABLE OF VARCHAR2(25)
The triples in the first model in delta_in
are copied to the first model in models_in
, and the entailment (rules index) in rules_index_in
is updated; then the triples in the second model (if any) in delta_in
are copied to the second model (if any) in models_in
, and the entailment in rules_index_in
is updated; and so on until all triples are copied and the entailment is updated. (The delta_in
parameter has no effect if incremental inference is not enabled for the entailment.)
An instance of MDSYS.RDFSA_LABELGEN or a subtype of it, defining the logic for generating Oracle Label Security (OLS) labels for inferred triples. What you specify for this parameter depends on whether you use the default label generator or a custom label generator:
If you use the default label generator, specify one of the following constants: SEM_RDFSA.LABELGEN_RULE
for Use Rule Label, SEM_RDFSA.LABELGEN_SUBJECT
for Use Subject Label, SEM_RDFSA.LABELGEN_PREDICATE
for Use Predicate Label, SEM_RDFSA.LABELGEN_OBJECT
for Use Object Label, SEM_RDFSA.LABELGEN_DOMINATING
for Use Dominating Label, SEM_RDFSA.LABELGEN_ANTECED
for Use Antecedent Labels. For a detailed explanation of each constant, see Section 5.2.2.4.
If you use a custom label generator, specify the custom label generator type. For information about creating and implementing a custom label generator, see Section 5.2.2.5.
Causes all triples from the specified named graphs (across all source models) to participate in named graph based global inference (NGGI, explained in Section 2.2.11.1). For example, include_named_g => sem_graphs('<urn:G1>','<urn:G2>')
implies that triples from named graphs G1
and G2
will be included in NGGI.
Its data type is SEM_GRAPHS, which has the following definition: TABLE OF VARCHAR2(4000)
.
Causes all triples with a null graph name in the specified models to participate in named graph based global inference (NGGI, explained in Section 2.2.11.1). For example, include_default_g => sem_models('m1')
causes all triples with a null graph name from model M1
to be included in NGGI.
Causes all triples, regardless of their graph name values, in the specified models to participate in named graph based global inference (NGGI, explained in Section 2.2.11.1). For example, include_all_g => sem_models('m2')
causes all triples in model M2
to be included in NGGI.
Assigns the specified graph name to all the new triples inferred by the named graph based global inference (NGGI, explained in Section 2.2.11.1).
Usage Notes
For the inf_components_in
parameter, you can specify any combination of the following keywords: SCOH
, COMPH
, DISJH
, SYMMH
, INVH
, SPIH
, MBRH
, SPOH
, DOMH
, RANH
, EQCH
, EQPH
, FPH
, IFPH
, DOM
, RAN
, SCO
, DISJ
, COMP
, INV
, SPO
, FP
, IFP
, SYMM
, TRANS
, DIF
, SAM
, CHAIN
, HASKEY
, ONEOF
, INTERSECT
, INTERSECTSCOH
, MBRLST
, PROPDISJH
, SKOSAXIOMS
, SNOMED
, SVFH
, THINGH
, THINGSAM
, UNION
, RDFP1
, RDFP2
, RDFP3
, RDFP4
, RDFP6
, RDFP7
, RDFP8AX
, RDFP8BX
, RDFP9
, RDFP10
, RDFP11
, RDFP12A
, RDFP12B
, RDFP12C
, RDFP13A
, RDFP13B
, RDFP13C
, RDFP14A
, RDFP14BX
, RDFP15
, RDFP16
, RDFS2
, RDFS3
, RDFS4a
, RDFS4b
, RDFS5
, RDFS6
, RDFS7
, RDFS8
, RDFS9
, RDFS10
, RDFS11
, RDFS12
, RDFS13
. For an explanation of the meaning of these keywords, see Table 9-1, where the keywords are listed in alphabetical order.
The default set of inference components for the OWLPrime vocabulary includes the following: SCOH
, COMPH
, DISJH
, SYMMH
, INVH
, SPIH
, SPOH
, DOMH
, RANH
, EQCH
, EQPH
, FPH
, IFPH
, SAMH
, DOM
, RAN
, SCO
, DISJ
, COMP
, INV
, SPO
, FP
, IFP
, SYMM
, TRANS
, DIF
, RDFP14A
, RDFP14BX
, RDFP15
, RDFP16
. However, note the following:
Component SAM
is not in this default OWLPrime list, because it tends to generate many new triples for some ontologies.
Effective with Release 11.2, the native OWL inference engine supports the following new inference components: CHAIN
, HASKEY
, INTERSECT
, INTERSECTSCOH
, MBRLST
, ONEOF
, PROPDISJH
, SKOSAXIOMS
, SNOMED
, SVFH
, THINGH
, THINGSAM
, UNION
. However, for backward compatibility, the OWLPrime rulebase and any existing rulebases do not include these new components by default; instead, to use these new inference components, you must specify them explicitly, and they are included in Table 9-1. The following example creates an OWLPrime entailment for two OWL ontologies named LUBM
and UNIV
. Because of the additional inference components specified, this entailment will include the new semantics introduced in those inference components.
EXECUTE sem_apis.create_entailment('lubm1000_idx',sem_models('lubm','univ'), sem_rulebases('owlprime'), SEM_APIS.REACH_CLOSURE, 'INTERSECT,INTERSECTSCOH,SVFH,THINGH,THINGSAM,UNION');
Table 9-1 Inferencing Keywords for inf_components_in Parameter
Keyword | Explanation |
---|---|
CHAIN |
Captures the property chain semantics defined in OWL 2. Only chains of length 2 are supported. By default, this is included in the |
COMPH |
Performs inference based on owl:complementOf assertions and the interaction of owl:complementOf with other language constructs. |
DIF |
Generates owl:differentFrom assertions based on the symmetricity of owl:differentFrom. |
DISJ |
Infers owl:differentFrom relationships at instance level using owl:disjointWith assertions. |
DISJH |
Performs inference based on owl:disjointWith assertions and their interactions with other language constructs. |
DOM |
Performs inference based on RDFS2. |
DOMH |
Performs inference based on rdfs:domain assertions and their interactions with other language constructs. |
EQCH |
Performs inference that are relevant to owl:equivalentClass. |
EQPH |
Performs inference that are relevant to owl:equivalentProperty. |
FP |
Performs instance-level inference using instances of owl:FunctionalProperty. |
FPH |
Performs inference using instances of owl:FunctionalProperty. |
HASKEY |
Covers the semantics behind "keys" defined in OWL 2. In OWL 2, a collection of properties can be treated as a key to a class expression. For efficiency, the size of the collection must not exceed 3. (New as of Release 11.2.) |
IFP |
Performs instance-level inference using instances of owl:InverseFunctionalProperty. |
IFPH |
Performs inference using instances of owl:InverseFunctionalProperty. |
INTERSECT |
Handles the core semantics of owl:intersectionOf. For example, if class C is the intersection of classes C1, C2 and C3, then C is a subclass of C1, C2, and C3. In addition, common instances of all C1, C2, and C3 are also instances of C. (New as of Release 11.2.) |
INTERSECTSCOH |
Handles the fact that an intersection is the maximal common subset. For example, if class C is the intersection of classes C1, C2, and C3, then any common subclass of all C1, C2, and C3 is a subclass of C. (New as of Release 11.2.) |
INV |
Performs instance-level inference using owl:inverseOf assertions. |
INVH |
Performs inference based on owl:inverseOf assertions and their interactions with other language constructs. |
MBRLST |
Captures the semantics that for any resource, every item in the list given as the value of the |
ONEOF |
Generates classification assertions based on the definition of the enumeration classes. In OWL, class extensions can be enumerated explicitly with the |
PROPDISJH |
Captures the interaction between |
RANH |
Performs inference based on |
RDFP* |
(The rules corresponding to components with a prefix of RDFP can be found in Completeness, decidability and complexity of entailment for RDF Schema and a semantic extension involving the OWL vocabulary, by H.J. Horst.) |
RDFS2, ... RDFS13 |
RDFS2, RDFS3, RDFS4a, RDFS4b, RDFS5, RDFS6, RDFS7, RDFS8, RDFS9, RDFS10, RDFS11, RDFS12, and RDFS13 are described in Section 7.3 of RDF Semantics ( |
SAM |
Performs inference about individuals based on existing assertions for those individuals and owl:sameAs. |
SAMH |
Infers owl:sameAs assertions using transitivity and symmetricity of owl:sameAs. |
SCO |
Performs inference based on RDFS9. |
SCOH |
Generates the subClassOf hierarchy based on existing rdfs:subClassOf assertions. Basically, C1 rdfs:subClassOf C2 and C2 rdfs:subClassOf C3 will infer C1 rdfs:subClassOf C3 based on transitivity. SCOH is also an alias of RDFS11. |
SKOSAXIOMS |
Captures most of the axioms defined in the SKOS detailed specification. By default, this is included in the |
Performs inference based on the semantics of the OWL 2 EL profile, which captures the expressiveness of SNOMED CT (Systematized Nomenclature of Medicine - Clinical Terms), which is one of the most expressive and complex medical terminologies. (New as of Release 11.2.) | |
SPIH |
Performs inference based on interactions between rdfs:subPropertyOf and owl:inverseOf assertions. |
SPO |
Performs inference based on RDFS7. |
SPOH |
Generates rdfs:subPropertyOf hierarchy based on transitivity of rdfs:subPropertyOf. It is an alias of RDFS5. |
SVFH |
Handles the following semantics that involves the interaction between owl:someValuesFrom and rdfs:subClassOf. Consider two existentia l restriction classes C1 and C2 that both use the same restriction property. Assume further that the owl:someValuesFrom constraint class for C1 is a subclass of that for C2. Then C1 can be inferred as a subclass of C2. (New as of Release 11.2.) |
SYMM |
Performs instance-level inference using instances of owl:SymmetricProperty. |
SYMH |
Performs inference for properties of type owl:SymmetricProperty. |
THINGH |
Handles the semantics that any defined OWL class is a subclass of owl:Thing. The consequence of this rule is that instances of all defined OWL classes will become instances of owl:Thing. The size of the inferred graph will very likely be bigger with this component selected. (New as of Release 11.2.) |
THINGSAM |
Handles the semantics that instances of owl:Thing are equal to (owl:sameAs) themselves. This component is provided for the convenience of some applications. Note that an application does not have to select this inference component to figure out an individual is equal to itself; this kind of information can easily be built in the application logic. (New as of Release 11.2.) |
TRANS |
Calculates transitive closure for instances of owl:TransitiveProperty. |
UNION |
Captures the core semantics of the |
To deselect a component, use the component name followed by a minus (-) sign. For example, SCOH-
deselects inference of the subClassOf
hierarchy.
For the options
parameter, you can enable the following options to override the default inferencing behavior:
COL_COMPRESS=T
creates temporary, intermediate working tables. This option can reduce the space required for such tables, and can improve the performance of the CREATE_ENTAILMENT operation with large data sets.
Note: You can specifyCOL_COMPRESS=T only on systems that support Hybrid Columnar Compression (HCC). For information about HCC, see Oracle Database Concepts. |
DISTANCE=T
generates ancillary distance information that is useful for semantic operators.
DOP=
n
specifies the degree of parallelism for parallel inference, which can improve inference performance. For information about parallel inference, see Section 2.2.10.
ENTAIL_ANYWAY=T
forces OWL inferencing to proceed and reuse existing inferred data (entailment) when the entailment has a valid status. By default, SEM_APIS.CREATE_ENTAILMENT quits immediately if there is already a valid entailment for the combination of models and rulebases.
HASH_PART=
n
creates the specified number of hash partitions for internal working tables. (The number must be a power of 2: 2, 4, 8, 16, 32, and so on.) You may want to specify a value if there are many distinct predicates in the semantic data model. In Oracle internal testing on benchmark ontologies, HASH_PART=32 worked well.
INC=T
enables incremental inference for the entailment. For information about incremental inference, see Section 2.2.9.
LOCAL_NG_INF=T
causes named graph based local inference (NGLI) to be used instead of named graph based global inference (NGGI). For information about NGLI, see Section 2.2.11.2.
OPT_SAMEAS=T
uses consolidated owl:sameAs
entailment for the entailment. If you specify this option, you cannot specify PROOF=T
. For information about optimizing owl:sameA
s inference, see Section 2.2.8.
RAW8=T
uses RAW8 datatypes for the auxiliary inference tables. This option can improve entailment performance by up to 30% in some cases.
PROOF=T
generates proof for inferred triples. Do not specify this option unless you need to; it slows inference performance because it causes more data to be generated. If you specify this option, you cannot specify OPT_SAMEAS=T
.
USER_RULES=T
causes any user-defined rules to be applied. If you specify this option, you cannot specify PROOF=T
or DISTANCE=T
, and you must accept the default value for the passes
parameter.
For the delta_in
parameter, inference performance is best if the value is small compared to the overall size of those models. In a typical scenario, the best results might be achieved when the delta contains fewer than 10,000 triples; however, some tests have shown significant inference performance improvements with deltas as large as 100,000 triples.
For the label_gen
parameter, if you want to use the default OLS label generator, specify the appropriate SEM_RDFSA package constant value from Table 9-2.
Table 9-2 SEM_RDFSA Package Constants for label_gen Parameter
Constant | Description |
---|---|
SEM_RDFSA.LABELGEN_SUBJECT |
Label generator that applies the label associated with the inferred triple's subject as the triple's label. |
SEM_RDFSA.LABELGEN_PREDICATE |
Label generator that applies the label associated with the inferred triple's subject as the triple's label. |
SEM_RDFSA.LABELGEN_OBJECT |
Label generator that applies the label associated with the inferred triple's subject as the triple's label. |
SEM_RDFSA.LABELGEN_RULE |
Label generator that applies the label associated with the rule that directly produced the inferred triple as the triple's label. If you specify this option, you must also specify |
SEM_RDFSA.LABELGEN_DOMINATING |
Label generator that computes a dominating label of all the available labels for the triple's components (subject, predicate, object, and rule), and applies it as the label for the inferred triple. |
Fine-Grained Access Control (VPD and OLS) Considerations
When fine-grained access control is enabled for a specific model using VPD or for the entire network using OLS, only a user with FULL access privileges to the associated policy may create an entailment. Full access privileges to a VPD policy are granted by setting the context attribute defined by the package constant sem_rdfsa.VPD_FULL_ACCESS
to 1 for the namespace associated with the VPD policy (see Section 5.1.1, "VPD Policy for RDF Data"). When OLS is enabled, full access privileges to the OLS policy are granted using the SA_USER_ADMIN.SET_USER_PRIVS
procedure. VPD policy is automatically enforced for any entailment created using at least one VPD enabled RDF model. As discussed in Section 5.1.1, the RDF metadata associated with the VPD policy may need to be maintained using the newly inferred data to ensure that the predefined VPD policies are not circumvented using inferred data.
Inferred triples accessed through generated labels might not be same as conceptual triples inferred directly from the user accessible triples and rules. The labels generated using a subset of triple components may be weaker than intended. For example, one of the antecedents for the inferred triple may have a higher label than any of the components of the triple. When the label is generated based on just the triple components, end users with no access to one of the antecedents may still have access to the inferred triple. Even when the antecedents are used for custom label generation, the generated label may be stronger than intended. The inference process is not exhaustive, and information pertaining to any alternate ways of inferring the same triple is not available. So, the label generated using a given set of antecedents may be too strong, because the user with access to all the triples in the alternate path could infer the triple with lower access.
Even when generating a label that dominates all its components and antecedents, the label may not be precise. This is the case when labels considered for dominating relationship have non-overlapping group information. For example, consider two labels L:C:NY
and L:C:NH
where L is a level, C is a component and NY and NH are two groups. A simple label that dominates these two labels is L:C:NY,NH
, and a true supremum for the two labels is L:C:US
, where US is parent group for both NY and NH. Unfortunately, neither of these two dominating labels is precise for the triple inferred from the triples with first two labels. If L:C:NY,NH
is used for the inferred triple, a user with membership in either of these groups has access to the inferred triple, whereas the same user does not have access to one of its antecedents. On the other hand, if L:C:US
is used for the inferred triple, a user with membership in both the groups and not in the US group will not be able to access the inferred triple, whereas that user could infer the triple by directly accessing its components and antecedents.
Because of these unique challenges with inferred triples, extra caution must be taken when choosing or implementing the label generator.
See also the OLS example in the Examples section.
Examples
The following example creates an entailment named OWLTST_IDX
using the OWLPrime rulebase, and it causes proof to be generated for inferred triples.
EXECUTE sem_apis.create_entailment('owltst_idx', sem_models('owltst'), sem_rulebases('OWLPRIME'), SEM_APIS.REACH_CLOSURE, null, 'PROOF=T');
The following example assumes an OLS environment. It creates a rulebase with a rule, and it creates an entailment.
-- Create an entailment with a rule. -- exec sdo_rdf_inference.create_entailment('contracts_rb'); insert into mdsys.rdfr_contracts_rb values ( 'projectLedBy', '(?x :drivenBy ?y) (?y :hasVP ?z)', NULL, '(?x :isLedBy ?z)', SDO_RDF_Aliases(SDO_RDF_Alias('','http://www.myorg.com/pred/'))); -- Assign sensitivity label for the predicate to be inferred. -- -- Yhe predicate label may be set globally or it can be assign to -- -- the one or the models used to infer the data – e.g: CONTRACTS. begin sem_rdfsa.set_predicate_label( model_name => 'rdf$global', predicate => 'http://www.myorg.com/pred/isLedBy', label_string => 'TS:US_SPCL'); end; / -- Create index with a specific label generator. -- begin sem_apis.create_entailment( entailment_name_in => 'contracts_inf', models_in => SDO_RDF_Models('contracts'), rulebases_in => SDO_RDF_Rulebases('contracts_rb'), options => 'USER_RULES=T', label_gen => sem_rdfsa.LABELGEN_PREDICATE); end; / -- Check for any label exceptions and update them accordingly. -- update mdsys.rdfi_contracts_inf set ctxt1 = 1100 where ctxt1 = -1; -- The new entailment is now ready for use in SEM_MATCH queries. --
Format
SEM_APIS.CREATE_RULEBASE(
rulebase_name IN VARCHAR2);
Description
Creates a rulebase.
Parameters
Name of the rulebase.
Usage Notes
This procedure creates a user-defined rulebase. After creating the rulebase, you can add rules to it. To cause the rules in the rulebase to be applied in a query of RDF data, you can specify the rulebase in the call to the SEM_MATCH table function.
Rules and rulebases are explained in Section 1.3.6. The SEM_MATCH table function is described in Section 1.6,
Examples
The following example creates a rulebase named family_rb. (It is an excerpt from Example 1-43 in Section 1.11.2.)
EXECUTE SEM_APIS.CREATE_RULEBASE('family_rb');
Format
SEM_APIS.CREATE_SEM_MODEL(
model_name IN VARCHAR2,
table_name IN VARCHAR2,
column_name IN VARCHAR2,
model_tablespace IN VARCHAR2 DEFAULT NULL);
Description
Creates a semantic technology model.
Parameters
Name of the model.
Name of the table to hold references to semantic technology data for this model.
Name of the column of type SDO_RDF_TRIPLE_S in table_name
.
Name of the tablespace for the tables and other database objects used by Oracle to support this model. The default value is the tablespace that was specified in the call to the SEM_APIS.CREATE_SEM_NETWORK procedure.
Usage Notes
You must create the table to hold references to semantic technology data before calling this procedure to create the semantic technology model. For more information, see Section 1.10.
This procedure adds the model to the MDSYS.SEM_MODEL$ view, which is described in Section 1.3.1.
This procedure is the only supported way to create a model. Do not use SQL INSERT statements with the MDSYS.SEM_MODEL$ view.
To delete a model, use the SEM_APIS.DROP_SEM_MODEL procedure.
Examples
The following example creates a semantic technology model named articles
. References to the triple data for the model will be stored in the TRIPLE column of the ARTICLES_RDF_DATA table. (This example is an excerpt from Example 1-42 in Section 1.11.2.)
EXECUTE SEM_APIS.CREATE_SEM_MODEL('articles', 'articles_rdf_data', 'triple');
The definition of the ARTICLES_RDF_DATA table is as follows:
CREATE TABLE articles_rdf_data (id NUMBER, triple SDO_RDF_TRIPLE_S);
Format
SEM_APIS.CREATE_SEM_NETWORK(
tablespace_name IN VARCHAR2
Description
Creates structures for persistent storage of semantic data.
Parameters
Name of the tablespace to be used for tables created by this procedure. This tablespace will be the default for all models that you create, although you can override the default when you create a model by specifying the model_tablespace
parameter in the call to the SEM_APIS.CREATE_SEM_MODEL procedure.
Usage Notes
This procedure creates system tables and other database objects used for semantic technology support.
You should create a tablespace for the semantic technology system tables and specify the tablespace name in the call to this procedure. (You should not specify the SYSTEM
tablespace.) The size needed for the tablespace that you create will depend on the amount of semantic technology data you plan to store.
You must connect to the database as a user with DBA privileges in order to call this procedure, and you should call the procedure only once for the database.
To drop these structures for persistent storage of semantic data, you must connect as a user with DBA privileges and call the SEM_APIS.DROP_SEM_NETWORK procedure.
Examples
The following example creates a tablespace for semantic technology system tables and creates structures for persistent storage of semantic data in this tablespace.
CREATE TABLESPACE rdf_tblspace DATAFILE '/oradata/orcl/rdf_tblspace.dat' SIZE 1024M REUSE AUTOEXTEND ON NEXT 256M MAXSIZE UNLIMITED SEGMENT SPACE MANAGEMENT AUTO; . . . EXECUTE SEM_APIS.CREATE_SEM_NETWORK('rdf_tblspace');
Format
SEM_APIS.CREATE_SOURCE_EXTERNAL_TABLE(
source_table IN VARCHAR2,
def_directory IN VARCHAR2,
log_directory IN VARCHAR2 DEFAULT NULL,
bad_directory IN VARCHAR2 DEFAULT NULL,
log_file IN VARCHAR2 DEFAULT NULL,
bad_file IN VARCHAR2 DEFAULT NULL,
parallel IN INTEGER DEFAULT NULL,
source_table_owner IN VARCHAR2 DEFAULT NULL,
flags IN VARCHAR2 DEFAULT NULL);
Description
Creates an external table to map an N-Triple or N-Quad format file into a table.
Parameters
Name of the external table to be created.
Database directory where the input files are located. To load from this staging table, you must have READ privilege on this directory.
Database directory where the log files will be generated when loading from the external table. If not specified, the value of the def_directory
parameter is used. When loading from the external table, you must have WRITE privilege on this directory.
Database directory where the bad files will be generated when loading from the external table. If not specified, the value of the def_directory
parameter is used. When loading from the external table, you must have WRITE privilege on this directory.
Name of the log file. If not specified, the name will be .generated automatically during a load operation.
Name of the bad file. If not specified, the name will be .generated automatically during a load operation.
Degree of parallelism to associate with the external table being created.
Owner for the external table being created. If not specified, the invoker becomes the owner.
(Reserved for future use)
Usage Notes
For more information and an example, see Section 1.7.1.1.2, "Loading N-Quad Format Data into a Staging Table Using an External Table".
Examples
The following example creates a source external table. (This example is an excerpt from Example 1-36 in Section 1.7.1.1.2.)
BEGIN sem_apis.create_source_external_table( source_table => 'stage_table_source' ,def_directory => 'DATA_DIR' ,bad_file => 'CLOBrows.bad' ); END;
Format
SEM_APIS.CREATE_VIRTUAL_MODEL(
vm_name IN VARCHAR2,
models IN SEM_MODELS,
rulebases IN SEM_RULEBASES DEFAULT NULL,
options IN VARCHAR2 DEFAULT NULL);
Description
Creates a virtual model containing the specified semantic models and rulebases.
Parameters
Name of the virtual model to be created.
One or more semantic model names. Its data type is SEM_MODELS, which has the following definition: TABLE OF VARCHAR2(25)
. At least one semantic model must be specified.
One or more rulebase names. Its data type is SEM_RULEBASES, which has the following definition: TABLE OF VARCHAR2(25)
. If this parameter is null, no rulebases are included in the virtual model definition. Rules and rulebases are explained in Section 1.3.6.
(Reserved for future use.)
Usage Notes
For an explanation of virtual models, including usage information, see Section 1.3.8.
An entailment must exist for each specified combination of semantic model and rulebase.
To create a virtual model, you must either be (A) the owner of each specified model and any corresponding entailments, or (B) a user with DBA privileges.
This procedure creates views with names in the following format:
SEMV_vm_name, which corresponds to a UNION ALL of the triples in each model and entailment. This view may contain duplicates.
SEMU_vm_name, which corresponds to a UNION of the triples in each model and entailment. This view will not contain duplicates (thus, the U in SEMU indicates unique).
However, the SEMU_vm_name view is not created if the virtual model contains only one semantic model and no entailment.
To use the example in Section 1.3.8 of a virtual model vm1 created from models m1, m2, m3, and with an entailment created for m1, m2 ,and m3 using the OWLPrime rulebase, this procedure will create the following two views (assuming that m1, m2, and m3, and the OWLPRIME entailment have internal model_id values 1, 2, 3, 4):
CREATE VIEW MDSYS.SEMV_VM1 AS SELECT start_node_id, p_value_id, canon_end_node_id, end_node_id FROM MDSYS.rdf_link$ WHERE model_id IN (1, 2, 3, 4); CREATE VIEW MDSYS.SEMU_VM1 AS SELECT start_node_id, p_value_id, canon_end_node_id, MAX(end_node_id) FROM MDSYS.rdf_link$ WHERE model_id IN (1, 2, 3, 4) GROUP BY start_node_id, p_value_id, canon_end_node_id;
The user that invokes this procedure will be the owner of the virtual model and will have SELECT WITH GRANT privileges on the SEMU_vm_name and SEMV_vm_name views. To query the corresponding virtual model, a user must have select privileges on these views.
Examples
The following example creates a virtual model named VM1
.
EXECUTE sem_apis.create_virtual_model('VM1', sem_models('model_1', 'model_2'), sem_rulebases('OWLPRIME'));
Format
SEM_APIS.DISABLE_CHANGE_TRACKING(
models_in IN SEM_MODELS);
Description
Disables change tracking for a specified set of models.
Parameters
One or more model names. Its data type is SEM_MODELS, which has the following definition: TABLE OF VARCHAR2(25)
Usage Notes
Disabling change tracking on a model automatically disables incremental inference on all entailment that use the model.
To use this procedure, you must be the owner of the specified model, and incremental inference must have been previously enabled.
For an explanation of incremental inference, including usage information, see Section 2.2.9.
Examples
The following example disables change tracking for the family
model.
EXECUTE sem_apis.disable_change_tracking(sem_models('family'));
Format
SEM_APIS.DISABLE_INC_INFERENCE(
entailment_name IN VARCHAR2);
Description
Disables incremental inference for a specified entailment (rules index).
Parameters
Name of the entailment for which to disable incremental inference.
Usage Notes
To use this procedure, you must be the owner of the specified entailment, and incremental inference must have been previously enabled by the SEM_APIS.ENABLE_INC_INFERENCE procedure.
Calling this procedure automatically disables change tracking for all models owned by the invoking user that were having changes tracked only because of this particular inference.
For an explanation of incremental inference, including usage information, see Section 2.2.9.
Examples
The following example enables incremental inference for the entailment named RDFS_RIX_FAMILY
.
EXECUTE sem_apis.disable_inc_inference('rdfs_rix_family');
Format
SEM_APIS.DROP_DATATYPE_INDEX(
datatype IN VARCHAR2,
force_drop IN BOOLEAN default FALSE);
De scription
Drops (deletes) an existing data type index.
Parameters
URI of the data type for the index to drop.
TRUE
forces the index to be dropped if an error occurs during the processing of the statement; FALSE
(the default) does not drop the index if an error occurs during the processing of the statement.
Usage Notes
You must have DBA privileges to call this procedure.
For an explanation of data type indexes, see Section 1.9.
Examples
The following example drops the data type index for xsd:string
typed literals and plain literals.
EXECUTE SEM_APIS.DROP_DATATYPE_INDEX('http://www.w3.org/2001/XMLSchema#string');
Format
SEM_APIS.DROP_ENTAILMENT(
entailment_name_in IN VARCHAR2,
named_g_in IN SEM_GRAPHS DEFAULT NULL,
dop IN INT DEFAULT 1);
Description
Drops (deletes) an entailment (rules index).
Parameters
Name of the entailment to be deleted.
Causes only the triples with the specified graph names in the entailment to be deleted. A null value (the default) drops the entire entailment.
For example, named_g_in => sem_graphs('<urn:G1>','<urn:G2>')
drops only the triples in entailment with graph names G1
and G2
; the rest of the entailment graph is not dropped.
Degree of parallelism for a parallel execution of triple deletion. Applies only if the named_g_in
parameter is not null.
Usage Notes
You can use this procedure to delete an entailment that you created using the SEM_APIS.CREATE_ENTAILMENT procedure.
If you drop only a subset of the entailment with specified named graphs (that is, when named_g_in
is not null) on an entailment with a VALID
or INCOMPLETE
status, then the resulting status of the entailment after the drop is set to INCOMPLETE
.
Examples
The following example deletes a entailment named OWLTST_IDX
.
EXECUTE sem_apis.drop_entailment('owltst_idx');
The following example deletes only inferred triples with graph names G1
and G2
that belong to the entailment named OWLNG_IDX
. Any inferred triples in the default graph and other named graphs remain in the entailment.
EXECUTE sem_apis.drop_entailment('owlng_idx',sem_graphs('<urn:G1>','<urn:G2>'));
Format
SEM_APIS.DROP_RULEBASE(
rulebase_name IN VARCHAR2);
Description
Deletes a rulebase.
Parameters
Name of the rulebase.
Usage Notes
This procedure deletes the specified rulebase, making it no longer available for use in calls to the SEM_MATCH table function. For information about rulebases, see Section 1.3.6.
Only the creator of a rulebase can delete the rulebase.
Examples
The following example drops the rulebase named family_rb
.
EXECUTE SEM_APIS.DROP_RULEBASE('family_rb');
Format
SEM_APIS.DROP_SEM_INDEX(
index_code IN VARCHAR2);
Description
Drops a semantic network index on the models and entailments of the semantic network.
Parameters
Index code string. Must match the index_code
value that was specified in an earlier call to the SEM_APIS.ADD_SEM_INDEX procedure.
Usage Notes
For an explanation of semantic network indexes, see Section 1.8.
Examples
The following example drops a semantic network index with the index code string pcsm
on the models and entailments of the semantic network.
EXECUTE SEM_APIS.DROP_SEM_INDEX('pscm');
Format
SEM_APIS.DROP_SEM_MODEL(
model_name IN VARCHAR2);
Description
Drops (deletes) a semantic technology model.
Parameters
Name of the model.
Usage Notes
This procedure deletes the model from the MDSYS.SEM_MODEL$ view, which is described in Section 1.3.1.
This procedure is the only supported way to delete a model. Do not use SQL DELETE statements with the MDSYS.SEM_MODEL$ view.
Only the creator of a model can delete the model.
Examples
The following example drops the semantic technology model named articles
.
EXECUTE SEM_APIS.DROP_SEM_MODEL('articles');
Format
SEM_APIS.DROP_SEM_NETWORK(
cascade IN BOOLEAN DEFAULT FALSE);
Description
Removes structures used for persistent storage of semantic data.
Parameters
TRUE
drops any existing semantic technology models and rulebases, and removes structures used for persistent storage of semantic data; FALSE
(the default) causes the operation to fail if any semantic technology models or rulebases exist.
Usage Notes
To remove structures used for persistent storage of semantic data, you must connect as a user with DBA privileges and call this procedure.
If any version-enabled models exist, this procedure will fail regardless of the value of the cascade
parameter.
Examples
The following example removes structures used for persistent storage of semantic data.
EXECUTE SEM_APIS.DROP_SEM_NETWORK;
Format
SEM_APIS.DROP_USER_INFERENCE_OBJS(
uname IN VARCHAR2);
Description
Drops (deletes) all rulebases and entailments owned by a specified database user.
Parameters
Name of a database user. (This value is case-sensitive; for example, HERMAN
and herman
are considered different users.)
Usage Notes
You must have sufficient privileges to delete rules and rulebases for the specified user.
This procedure does not delete the database user. It deletes only RDF rulebases and entailments owned by that user.
Examples
The following example deletes all rulebases and entailments owned by user SCOTT
.
EXECUTE SEM_APIS.DROP_USER_INFERENCE_OBJS('SCOTT'); PL/SQL procedure successfully completed.
Format
SEM_APIS.DROP_VIRTUAL_MODEL(
vm_name IN VARCHAR2);
Description
Drops (deletes) a virtual model.
Parameters
Name of the virtual model to be deleted.
Usage Notes
You can use this procedure to delete a virtual model that you created using the SEM_APIS.CREATE_VIRTUAL_MODEL procedure. A virtual model is deleted automatically if any of its component models, rulebases, or entailment are deleted.
To use this procedure, you must be the owner of the specified virtual model.
For an explanation of virtual models, including usage information, see Section 1.3.8.
Examples
The following example deletes a virtual model named VM1
.
EXECUTE sem_apis.drop_virtual_model('VM1');
Format
SEM_APIS.ENABLE_CHANGE_TRACKING(
models_in IN SEM_MODELS);
Description
Enables change tracking for a specified set of models.
Parameters
One or more model names. Its data type is SEM_MODELS, which has the following definition: TABLE OF VARCHAR2(25)
Usage Notes
Change tracking must be enabled on a model before incremental inference can be enabled on any entailments that use the model.
To use this procedure, you must be the owner of the specified model or models.
If the owner of an entailment is also an owner of any underlying models, then enabling incremental inference on the entailment (by calling the SEM_APIS.ENABLE_INC_INFERENCE procedure) automatically enables change tracking on those models owned by that user.
To disable change tracking for a set of models, use the SEM_APIS.DISABLE_CHANGE_TRACKING procedure.
For an explanation of incremental inference, including usage information, see Section 2.2.9.
Examples
The following example enables change tracking for the family
model.
EXECUTE sem_apis.enable_change_tracking(sem_models('family'));
Format
SEM_APIS.ENABLE_INC_INFERENCE(
entailment_name IN VARCHAR2);
Description
Enables incremental inference for a specified entailment (rules index).
Parameters
Name of the entailment for which to enable incremental inference.
Usage Notes
To use this procedure, you must be the owner of the specified entailment.
Before this procedure is executed, all underlying models involved in the entailment must have change tracking enabled. If the owner of the entailment is also an owner of any underlying models, calling this procedure automatically enables change tracking on those models. However, if some underlying model are not owned by the owner of the entailment, the appropriate model owners must first call the SEM_APIS.ENABLE_CHANGE_TRACKING procedure to enable change tracking on those models.
To disable incremental inference for an entailment, use the SEM_APIS.DISABLE_INC_INFERENCE procedure.
For an explanation of incremental inference, including usage information, see Section 2.2.9.
Examples
The following example enables incremental inference for the entailment named RDFS_RIX_FAMILY
.
EXECUTE sem_apis.enable_inc_inference('rdfs_rix_family');
Format
SEM_APIS.GET_CHANGE_TRACKING_INFO(
model_name IN VARCHAR2,
enabled OUT BOOLEAN,
tracking_start_time OUT TIMESTAMP);
Description
Returns change tracking information for a model.
Parameters
Name of the semantic technology model.
Boolean value returned by the procedure: TRUE
if change tracking is enabled for the model, or FALSE
if change tacking is not enabled for the model.
Timestamp indicating when change tracking was enabled for the model (if it is enabled).
Usage Notes
The model_name
value must match a value in the MODEL_NAME column in the MDSYS.SEM_MODEL$ view, which is described in Section 1.3.1.
To enable change tracking for a set of models, use the SEM_APIS.ENABLE_CHANGE_TRACKING procedure.
For an explanation of incremental inference, including usage information, see Section 2.2.9.
Examples
The following example displays change tracking information for a model.
DECLARE bEnabled boolean; tsEnabled timestamp; BEGIN EXECUTE IMMEDIATE 'create table m1 (t SDO_RDF_TRIPLE_S)'; sem_apis.create_sem_model('m1','m1','t'); sem_apis.enable_change_tracking(sem_models('m1')); sem_apis.get_change_tracking_info('m1', bEnabled, tsEnabled); dbms_output.put_line('is enabled:' || case when bEnabled then 'true' else 'false' end); dbms_output.put_line('enabled at:' || tsEnabled); END; /
Format
SEM_APIS.GET_INC_INF_INFO(
entailment_name IN VARCHAR2,
enabled OUT BOOLEAN,
prev_inf_start_time OUT TIMESTAMP);
Description
Returns incremental inference information for an entailment.
Parameters
Name of the entailment.
Boolean value returned by the procedure: TRUE
if incremental inference is enabled for the entailment, or FALSE
if incremental inference is not enabled for the entailment.
Timestamp indicating when the entailment was most recently updated (if incremental inference is enabled).
Usage Notes
To enable incremental inference for an entailment, use the SEM_APIS.ENABLE_INC_INFERENCE procedure.
For an explanation of incremental inference, including usage information, see Section 2.2.9.
Examples
The following example displays incremental inference information for an entailment.
DECLARE bEnabled boolean; tsEnabled timestamp; DECLARE EXECUTE IMMEDIATE 'create table m1 (t SDO_RDF_TRIPLE_S)'; sem_apis.create_sem_model('m1','m1','t'); sem_apis.create_entailment('m1_inf',sem_models('m1'), sem_rulebases('owlprime'),null,null,'INC=T'); sem_apis.get_inc_inf_info('m1_inf', bEnabled, tsEnabled); dbms_output.put_line('is enabled:' || case when bEnabled then 'true' else 'false' end); dbms_output.put_line('enabled at:' || tsEnabled); END /
Format
SEM_APIS.GET_MODEL_ID(
model_name IN VARCHAR2
) RETURN NUMBER;
Description
Returns the model ID number of a semantic technology model.
Parameters
Name of the semantic technology model.
Usage Notes
The model_name
value must match a value in the MODEL_NAME column in the MDSYS.SEM_MODEL$ view, which is described in Section 1.3.1.
Examples
The following example returns the model ID number for the model named articles
. (This example is an excerpt from Example 1-42 in Section 1.11.2.)
SELECT SEM_APIS.GET_MODEL_ID('articles') AS model_id FROM DUAL; MODEL_ID ---------- 1
Format
SEM_APIS.GET_MODEL_NAME(
model_id IN NUMBER
) RETURN VARCHAR2;
Description
Returns the model name of a semantic technology model.
Parameters
ID number of the semantic technology model.
Usage Notes
The model_id
value must match a value in the MODEL_ID column in the MDSYS.SEM_MODEL$ view, which is described in Section 1.3.1.
Examples
The following example returns the model ID number for the model with the ID value of 1. This example is an excerpt from Example 1-42 in Section 1.11.2.)
SQL> SELECT SEM_APIS.GET_MODEL_NAME(1) AS model_name FROM DUAL; MODEL_NAME -------------------------------------------------------------------------------- ARTICLES
Format
SEM_APIS.GET_TRIPLE_ID(
model_id IN NUMBER,
subject IN VARCHAR2,
property IN VARCHAR2,
object IN VARCHAR2
) RETURN VARCHAR2;
or
SEM_APIS.GET_TRIPLE_ID(
model_name IN VARCHAR2,
subject IN VARCHAR2,
property IN VARCHAR2,
object IN VARCHAR2
) RETURN VARCHAR2;
Description
Returns the ID of a triple in the specified semantic technology model, or a null value if the triple does not exist.
Parameters
ID number of the semantic technology model. Must match a value in the MODEL_ID column of the MDSYS.SEM_MODEL$ view, which is described in Section 1.3.1.
Name of the semantic technology model. Must match a value in the MODEL_NAME column of the MDSYS.SEM_MODEL$ view, which is described in Section 1.3.1.
Subject. Must match a value in the VALUE_NAME column of the MDSYS.RDF_VALUE$ table, which is described in Section 1.3.2.
Property. Must match a value in the VALUE_NAME column of the MDSYS.RDF_VALUE$ table, which is described in Section 1.3.2.
Object. Must match a value in the VALUE_NAME column of the MDSYS.RDF_VALUE$ table, which is described in Section 1.3.2.
Usage Notes
This function has two formats, enabling you to specify the semantic technology model by its model number or its name.
Examples
The following example returns the ID number of a triple. (This example is an excerpt from Example 1-42 in Section 1.11.2.)
SELECT SEM_APIS.GET_TRIPLE_ID( 'articles', 'http://nature.example.com/Article2', 'http://purl.org/dc/terms/references', 'http://nature.example.com/Article3') AS RDF_triple_id FROM DUAL; RDF_TRIPLE_ID -------------------------------------------------------------------------------- 2_9F2BFF05DA0672E_90D25A8B08C653A_46854582F25E8AC5
Format
SEM_APIS.GETV$DATETIMETZVAL(
value_type IN VARCHAR2,
vname_prefix IN VARCHAR2,
vname_suffix IN VARCHAR2,
literal_type IN VARCHAR2,
language_type IN VARCHAR2,
) RETURN NUMBER;
Description
Returns a TIMESTAMP WITH TIME ZONE value for xsd:dateTime typed literals, and returns a null value for all other RDF terms. Greenwich Mean Time is used as the default time zone for xsd:dateTime values without time zones.
Parameters
Type of the RDF term.
Prefix value of the RDF term.
Suffix value of the RDF term.
Literal type of the RDF term.
Language type of the RDF term.
Usage Notes
For better performance, consider creating a function-based index on this function. For more information, see Section 1.6.7.2.
Examples
The following example returns TIMESTAMP WITH TIME ZONE values for all xsd:dateTime literals in the MDSYS.RDF_VALUE$ table:
SELECT SEM_APIS.GETV$DATETIMETZVAL(value_type, vname_prefix, vname_suffix, literal_type, language_type) FROM MDSYS.RDF_VALUE$;
Format
SEM_APIS.GETV$DATETZVAL(
value_type IN VARCHAR2,
vname_prefix IN VARCHAR2,
vname_suffix IN VARCHAR2,
literal_type IN VARCHAR2,
language_type IN VARCHAR2,
) RETURN TIMESTAMP WITH TIME ZONE;
Description
Returns a TIMESTAMP WITH TIME ZONE value for xsd:date typed literals, and returns a null value for all other RDF terms. Greenwich Mean Time is used as the default time zone for xsd:date values without time zones.
Parameters
Type of the RDF term.
Prefix value of the RDF term.
Suffix value of the RDF term.
Literal type of the RDF term.
Language type of the RDF term.
Usage Notes
For better performance, consider creating a function-based index on this function. For more information, see Section 1.6.7.2.
Examples
The following example returns TIMESTAMP WITH TIME ZONE values for all xsd:date literals in the MDSYS.RDF_VALUE$ table:
SELECT SEM_APIS.GETV$DATETZVAL(value_type, vname_prefix, vname_suffix, literal_type, language_type) FROM MDSYS.RDF_VALUE$;
Format
SEM_APIS.GETV$NUMERICVAL(
value_type IN VARCHAR2,
vname_prefix IN VARCHAR2,
vname_suffix IN VARCHAR2,
literal_type IN VARCHAR2,
language_type IN VARCHAR2,
) RETURN NUMBER;
Description
Returns a numeric value for XML Schema numeric typed literals, and returns a null value for all other RDF terms.
Parameters
Type of the RDF term.
Prefix value of the RDF term.
Suffix value of the RDF term.
Literal type of the RDF term.
Language type of the RDF term.
Usage Notes
For better performance, consider creating a function-based index on this function. For more information, see Section 1.6.7.2.
Examples
The following example returns numeric values for all numeric literals in the MDSYS.RDF_VALUE$ table:
SELECT SEM_APIS.GETV$NUMERICVAL(value_type, vname_prefix, vname_suffix, literal_type, language_type) FROM MDSYS.RDF_VALUE$;
Format
SEM_APIS.GETV$STRINGVAL(
value_type IN VARCHAR2,
vname_prefix IN VARCHAR2,
vname_suffix IN VARCHAR2,
literal_type IN VARCHAR2,
language_type IN VARCHAR2,
) RETURN TIMESTAMP WITH TIME ZONE;
Description
Returns a VARCHAR2 string of the lexical form of plain literals and xsd:string typed literals, and returns a null value for all other RDF terms. CHR(0) is returned for empty literals.