Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 844

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="14. RDF Data Access and Data Management" />
  <meta name="dc.subject" content="14. RDF Data Access and Data Management" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="rdfandsparql.html" title="Chapter Contents" />
  <link rel="prev" href=".html" title="" />
  <link rel="next" href="rdfsparql.html" title="SPARQL" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>14. RDF Data Access and Data Management</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="rdfdatarepresentation" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>14. RDF Data Access and Data Management</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="rdfandsparql.html">Chapter Contents</a> | <a class="link" href="rdfandsparql.html" title="RDF Data Access and Data Management">Prev</a> | <a class="link" href="rdfsparql.html" title="SPARQL">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div class="selected">
      <a href="rdfandsparql.html">RDF Data Access and Data Management</a>
   </div>
    <br />
   <div class="selected">
      <a href="rdfdatarepresentation.html">Data Representation</a>
    <div>
        <a href="#rdfiriidtype" title="IRI_ID Type">IRI_ID Type</a>
        <a href="#rdfboxtype" title="RDF_BOX Type">RDF_BOX Type</a>
        <a href="#rdfquadtables" title="RDF_QUAD and other tables">RDF_QUAD and other tables</a>
        <a href="#rdfsqlmodes" title="Short, Long and SQL Values">Short, Long and SQL Values</a>
        <a href="#rdfsqlsparqlresolve" title="Programatically resolving DB.DBA.RDF_QUAD.O to SQL">Programatically resolving DB.DBA.RDF_QUAD.O to SQL</a>
        <a href="#rdfxmlschemacompat" title="Special Cases and XML Schema Compatibility">Special Cases and XML Schema Compatibility</a>
        <a href="#rdfquietcast" title="SQL Compiler Support - QUIETCAST option">SQL Compiler Support - QUIETCAST option</a>
        <a href="#rdfdynamiclocal" title="Dynamic Renaming of Local IRI's">Dynamic Renaming of Local IRI&#39;s</a>
    </div>
   </div>
   <div>
      <a href="rdfsparql.html">SPARQL</a>
   </div>
   <div>
      <a href="sparqlextensions.html">Extensions</a>
   </div>
   <div>
      <a href="rdfgraphsecurity.html">RDF Graphs Security</a>
   </div>
   <div>
      <a href="rdfviews.html">Linked Data Views over RDBMS Data Source</a>
   </div>
   <div>
      <a href="rdfrdfviewgnr.html">Automated Generation of RDF Views over Relational Data Sources</a>
   </div>
   <div>
      <a href="rdfviewsenterpr.html">Examples of Linked Data Views</a>
   </div>
   <div>
      <a href="rdfinsertmethods.html">RDF Insert Methods in Virtuoso</a>
   </div>
   <div>
      <a href="virtuososponger.html">RDFizer Middleware (Sponger)</a>
   </div>
   <div>
      <a href="virtuosospongerfacetinstall.html">Virtuoso Faceted Browser Installation and configuration</a>
   </div>
   <div>
      <a href="virtuosospongerfacent.html">Virtuoso Faceted Web Service</a>
   </div>
   <div>
      <a href="rdfiridereferencing.html">Linked Data</a>
   </div>
   <div>
      <a href="rdfsparqlrule.html">Inference Rules &amp; Reasoning</a>
   </div>
   <div>
      <a href="rdfsparqlgeospat.html">RDF and Geometry</a>
   </div>
   <div>
      <a href="rdfperformancetuning.html">RDF Performance Tuning</a>
   </div>
   <div>
      <a href="rdfnativestorageproviders.html">RDF Data Access Providers (Drivers)</a>
   </div>
   <div>
      <a href="rdfgraphreplication.html">RDF Graph Replication</a>
   </div>
    <br />
  </div>
  <div id="text">
    <a name="rdfdatarepresentation" />
    <h2>14.1. Data Representation</h2>
<p>This section covers how Virtuoso stores RDF triples. The IRI_ID built-in data type is introduced, along with the default table structures used for triple persistency.
These details are mostly hidden from users of RDF, thus this section is not necessary reading for typical use of Virtuoso with RDF.
</p>
<a name="rdfiriidtype" />
    <h3>14.1.1. IRI_ID Type</h3>
<p>The central notion of RDF is the IRI, or URI, which serves as the globally unique label of named nodes. The subject and predicate of a triple are always IRI&#39;s and the object may be an IRI or any other XML Schema scalar data type. In any case, an IRI is always distinct from any instance of any other data type.</p>
<p>Virtuoso supports a native IRI_ID data type, internally an unsigned 32 bit or unsigned 64 bit integer value.
Small databases can use 32 bit values but if database becomes big then the administrator should execute
<span class="computeroutput">DB.DBA.RDF_64BIT_UPGRADE</span>() procedure that will switch to 64-bit values. This procedure takes time so if it is known in advance that the database will grow to billions of nodes then it could be convenient to upgrade it while it is empty.
An IRI_ID is never equal to any instance of any other type.</p>
<p>Thus, the object column of a table storing triples can be declared as ANY and IRI values will be distinguishable without recourse to any extra flag and IRI&#39;s will naturally occupy their own contiguous segment in the ANY type collation sequence. Indices can be defined over such columns. An IRI_ID is never automatically cast into any other type nor any other type into IRI_ID.</p>
<p>The functions iri_id_num (in i IRI_ID) and iri_id_from_num (in n INT) convert between signed integers and IRI_ID&#39;s. The function isiri_id (in i any) returns nonzero if the argument is of type IRI_ID, zero otherwise.</p>
<p>The syntax for an IRI_ID literal is <strong>#i&lt;NNN&gt;</strong> or <strong>#ib&lt;NNN&gt;</strong>, where <strong>&lt;NNN&gt;</strong> is up to 20 decimal digits. <strong>#i12345</strong> is equal to <strong>iri_id_from_num (12345)</strong> and <strong>#ib12345</strong> is equal to <strong>iri_id_from_num (12345) + min_64bit_bnode_iri_id ()</strong>.</p>	
<p>When received by a SQL client application, the ODBC driver or
interactive SQL will bind an IRI_ID to a character buffer, producing
the <strong>#i&lt;NNN&gt;</strong> syntax. When passing IRI_ID&#39;s from a client, one can pass an
integer and use the iri_id_from_num () function in the statement to
convert server side. A SQL client will normally not be exposed to
IRI_ID&#39;s since the SPARQL implementation returns IRI&#39;s in their text
form, not as internal id&#39;s. These will however be seen if reading the
internal tables directly.</p>
<div class="note">
      <div class="notetitle">Note:</div>
      <p>Nobody, even DBA, should write directly to internal RDF tables, because some data from that tables are cached in a special way and cache is not automatically updated when content of tables has changed.</p>
    </div>
<p>
      <strong>Example</strong>
    </p>
<p>The following example demonstrates IRI type usage as Virtuoso PL function parameter:</p>
<div>
      <pre class="programlisting">
SQL&gt;create procedure vs_property_label (in _uri varchar)
  {
    declare res varchar;
    result_names (res);
    for (sparql define input:storage &quot;&quot; select distinct ?graph_rvr_fixed where { graph `iri(?:_uri)` { ?qmv virtrdf:qmGraphRange-rvrFixedValue ?graph_rvr_fixed}})
    do {
      result (&quot;graph_rvr_fixed&quot;);
    }
  }
;
Done. -- 0 msec.

SQL&gt;select vs_property_label(&#39;http://www.openlinksw.com/schemas/virtrdf#&#39;);
res
VARCHAR
_______________________________________________________________________________

http://demo.openlinksw.com/Northwind
http://demo.openlinksw.com/tpch
http://demo.openlinksw.com/tpcd
http://demo.openlinksw.com/bsbm
http://demo.openlinksw.com/tutorial/Northwind
http://demo.openlinksw.com/thalia
http://demo.openlinksw.com/tutorial_view
http://demo.openlinksw.com/ecrm
http://demo.openlinksw.com/sys
http://demo.openlinksw.com/Doc
http://demo.openlinksw.com/informix/stores_demo
http://demo.openlinksw.com/oraclehr
http://demo.openlinksw.com/db2sample
http://demo.openlinksw.com/ingrestut
http://demo.openlinksw.com/sybasepubs2
http://demo.openlinksw.com/MSPetShop#
http://demo.openlinksw.com/oracle#
http://demo.openlinksw.com/progress/isports
http://demo.openlinksw.com/wpl_v
http://demo.openlinksw.com/mw_v
http://demo.openlinksw.com/drupal_v
0

22 Rows. -- 241 msec.
</pre>
    </div>
<br />
<a name="rdfboxtype" />
    <h3>14.1.2. RDF_BOX Type</h3>
<p>While strings, numbers, dates and XML entities are &quot;native&quot; SQL datatypes,
RDF literal with non-default type or language have no exact matches among standard SQL types.
Virtuoso introduces a special data type called &quot;RDF_BOX&quot; in order to handle that cases.
Instance of RDF_BOX consists of data type, language, the content (or beginning characters of a long content)
and a possible reference to DB.DBA.RDF_OBJ table if the object is too long to be held in-line in some table or should be outlined for free-text indexing.</p>
<p>Usually applications do not need to access internals of an RDF boxes. This datatype is used in system tables but almost all SPARQL and RDF operations use standard SQL datatypes for arguments and return values.</p>
<br />
<a name="rdfquadtables" />
    <h3>14.1.3. RDF_QUAD and other tables</h3>
<p>The main tables of the default RDF storage system are:</p>
<div>
      <pre class="programlisting">
create table DB.DBA.RDF_QUAD (
  G IRI_ID,
  S IRI_ID,
  P IRI_ID,
  O any,
  primary key (G,S,P,O) );
create bitmap index RDF_QUAD_OGPS on DB.DBA.RDF_QUAD (O, G, P, S);
</pre>
    </div>
<p>Each triple (more correctly, each quad) is represented by one row in RDF_QUAD.
The columns represent the graph, subject, predicate and object.
The IRI_ID type columns reference RDF_IRI, which translates the internal id to the external name of the IRI.
The O column is of type ANY.
If the O value is a non-string SQL scalar, such as a number or date or IRI, it is stored in its native binary representation.
If it is a &quot;very short&quot; string (20 characters or less), it is also stored &quot;as is&quot;.
Long strings and RDF literal with non-default type or language are stored as RDF_BOX values.
Instance of rdf_box consists of data type, language, the content (or beginning characters of a long content)
and a possible reference to RDF_OBJ if the object is too long to be held in-line in this table or should be outlined for free-text indexing.
</p>
<div>
      <pre class="programlisting">
create table DB.DBA.RDF_PREFIX (
  RP_NAME varchar primary key,
  RP_ID int not null unique );
create table DB.DBA.RDF_IRI (
  RI_NAME varchar primary key,
  RI_ID IRI_ID not null unique );
</pre>
    </div>
<p>These two tables store a mapping between internal IRI id&#39;s and their external string form.
A memory-resident cache contains recently used IRIs to reduce access to this table.
Function id_to_iri (in id IRI_ID) returns the IRI by its ID.
Function iri_to_id (in iri varchar, in may_create_new_id) returns an IRI_ID for given string;
if the string is not used before as an IRI then either NULL is returned or a new ID is allocated, depending on the second argument.
</p>
<div>
      <pre class="programlisting">
create table DB.DBA.RDF_OBJ (
  RO_ID integer primary key,
    RO_VAL varchar,
  RO_LONG long varchar,
  RO_DIGEST any
)
create index RO_VAL on DB.DBA.RDF_OBJ (RO_VAL)
create index RO_DIGEST on DB.DBA.RDF_OBJ (RO_DIGEST)
;
</pre>
    </div>
<p>When an O value of RDF_QUAD is longer than a certain limit or should be free-text indexed, the value is stored in this table.
Depending on the length of the value, it goes into the varchar or the long varchar column.
The RO_ID is contained in rdf_box object that is stored in the O column.
Still, the truncated value of O can be used for determining equality and range matching,
even if &lt; and &gt; of closely matching values need to look at the real string in RDF_OBJ.
When RO_LONG is used to store very long value, RO_VAL contains a simple checksum of the value, to accelerate search for identical values when the table is populated by new values.
</p>
<div>
      <pre class="programlisting">
create table DB.DBA.RDF_DATATYPE (
    RDT_IID IRI_ID not null primary key,
    RDT_TWOBYTE integer not null unique,
    RDT_QNAME varchar );
</pre>
    </div>
<p>The XML Schema data type of a typed string O represented as 2 bytes in the O varchar value. This table maps this into the broader IRI space where the type URI is given an IRI number.</p>
<div>
      <pre class="programlisting">
create table DB.DBA.RDF_LANGUAGE (
    RL_ID varchar not null primary key,
    RL_TWOBYTE integer not null unique );
</pre>
    </div>
<p>The varchar representation of a O which is a string with language has a two byte field for language. This table maps the short integer language id to the real language name such as &#39;en&#39;, &#39;en-US&#39; or &#39;x-any&#39;.</p>
<p>
      <strong>Note that unlike datatype names, language names are not URIs.</strong>
    </p>
<p>A short integer value can be used in both RDF_DATATYPE and RDF_LANGUAGE tables for two different purposes. E.g. an integer 257 is for &#39;unspecified datatype&#39; as well as for &#39;unspecified language&#39;.</p>
<br />
<a name="rdfsqlmodes" />
    <h3>14.1.4. Short, Long and SQL Values</h3>
<p>When processing an O, the SPARQL implementation may have it in one of three internal formats, called &quot;valmodes&quot;. The below cases apply for strings:</p>
<p>The short format is the format where an O is stored in RDF_QUAD.</p>
<p>The long value is similar to short one but an rdf_box object, that consists of six fields:</p>
<ul>
<li>short integer id of type referencing RDT_TWOBYTE, 257   if the type is not specified,</li>
<li>the string as inlined in O or as stored in RO_VAL or   RO_LONG,</li>
<li>the RO_ID if the string is from RDF_OBJ (otherwise   zero),</li>
<li>the short integer id of language referencing RL_TWOBYTE, 257 if the language is not specified,</li>
<li>flag whether the stored string value is complete or it is only the beginning that is inlined in O.</li>
</ul>
<p>The SQL value is the string as a narrow string representing the UTF8 encoding of the value, stripped of data type and language tag.</p>
<p>The SQL form of an IRI is the string. The long and short forms are the IRI_ID referencing RU_IRI_ID of RDF_URL.</p>
<p>For all non-string, non-IRI types, the short, long and SQL values are the same SQL scalar of the appropriate native SQL type. A SQL host variable meant to receive an O should be of the ANY type.</p>
<p>The SPARQL implementation will usually translate results to the SQL format before returning them.
Internally, it uses the shortest possible form suited to the operation. For equalities and joining, the
short form is always good. For range comparisons, the long form is needed etc. For arithmetic,
all three forms will do since the arguments are expected to be numbers which are stored as their binary
selves in O, thus the O column unaltered and uncast will do as an argument of arithmetic or numeric
comparison with, say, SQL literal constants.</p>
<br />
<a name="rdfsqlsparqlresolve" />
    <h3>14.1.5. Programatically resolving DB.DBA.RDF_QUAD.O to SQL</h3>
<p>This section describes how to resolve programatically the internal representation of DB.DBA.RDF_QUAD.O to its SQL value.</p>
<p>When operating over RDF_QUAD table directly, in order to transform all values obtained from column
O to the explicit SQL type in a programmatic way, should be used the following hints depending on the case:
</p>
<ul>
  <li>The SQL value can be extracted as <strong>__ro2sq(O)</strong>.</li>
  <li>The datatype can be extracted as <strong>DB.DBA.RDF_DATATYPE_OF_OBJ (O)</strong> if IRI_ID of the type is enough or <strong>__ro2sq ( DB.DBA.RDF_DATATYPE_OF_OBJ(O))</strong>
      </li>
  <li>The language can be extracted as <strong>DB.DBA.RDF_LANGUAGE_OF_OBJ (O)</strong>.</li>
</ul>

<p>It could be helpful to be created an RDF View for a custom table with formats rdfdf:default or rdfdf:default-nullable
for columns similar to O, and let SPARQL perform the rest.</p>

<p>To track SPARQL, use the following functions:</p>

<div>
      <pre class="programlisting">
select sparql_to_sql_text (&#39;query text here without a leading SPARQL keyword and trailing semicolon&#39;)
</pre>
    </div>
<p>or</p>
<div>
      <pre class="programlisting">
string_to_file (&#39;filename.sql&#39;, sparql_to_sql_text (&#39;query text&#39;), -2);
</pre>
    </div>
<p>So for example to track the following SPARQL query:</p>
<div>
      <pre class="programlisting">
SPARQL define input:storage &quot;&quot;
select distinct ?graph_rvr_fixed
from &lt;http://www.openlinksw.com/schemas/virtrdf#&gt;
where { ?qmv virtrdf:qmGraphRange-rvrFixedValue ?graph_rvr_fixed }
</pre>
    </div>
<p>execute</p>
<div>
      <pre class="programlisting">
SQL&gt;select sparql_to_sql_text(&#39;define input:storage &quot;&quot; select distinct ?graph_rvr_fixed from &lt;http://www.openlinksw.com/schemas/virtrdf#&gt; where { ?qmv virtrdf:qmGraphRange-rvrFixedValue ?graph_rvr_fixed }&#39;);
callret
VARCHAR
_______________________________________________________________________________

 SELECT  __ro2sq (&quot;s-1-0_rbc&quot;.&quot;graph_rvr_fixed&quot;) AS &quot;graph_rvr_fixed&quot; FROM (SELECT DISTINCT __rdf_sqlval_of_obj ( /*retval[*/ &quot;s-1-1-t0&quot;.&quot;O&quot; /* graph_
rvr_fixed */ /*]retval*/ ) AS /*tmpl*/ &quot;graph_rvr_fixed&quot;
    FROM DB.DBA.RDF_QUAD AS &quot;s-1-1-t0&quot;
    WHERE /* field equal to URI ref */
        &quot;s-1-1-t0&quot;.&quot;G&quot; = __i2idn ( /* UNAME as sqlval */ __box_flags_tweak ( &#39;http://www.openlinksw.com/schemas/virtrdf#&#39; , 1))
        AND  /* field equal to URI ref */
        &quot;s-1-1-t0&quot;.&quot;P&quot; = __i2idn ( /* UNAME as sqlval */ __box_flags_tweak ( &#39;http://www.openlinksw.com/schemas/virtrdf#qmGraphRange-rvrFixedValue&#39; ,
1))
OPTION (QUIETCAST)) AS &quot;s-1-0_rbc&quot;

1 Rows. -- 321 msec.
</pre>
    </div>
<p>or</p>
<div>
      <pre class="programlisting">
SQL&gt;string_to_file (&#39;mytest.sql&#39;, sparql_to_sql_text (&#39;define input:storage &quot;&quot; select distinct ?graph_rvr_fixed from &lt;http://www.openlinksw.com/schemas/virtrdf#&gt; where { ?qmv virtrdf:qmGraphRange-rvrFixedValue ?graph_rvr_fixed }&#39;), -2);
</pre>
    </div>
<p>As result will be created file with the given name, i.e. mytest.sql and its content should be:</p>
<div>
      <pre class="programlisting">
 SELECT  __ro2sq (&quot;s-1-0_rbc&quot;.&quot;graph_rvr_fixed&quot;) AS &quot;graph_rvr_fixed&quot; FROM (SELECT DISTINCT __rdf_sqlval_of_obj ( /*retval[*/ &quot;s-1-1-t0&quot;.&quot;O&quot; /* graph_rvr_fixed */ /*]retval*/ ) AS /*tmpl*/ &quot;graph_rvr_fixed&quot;
    FROM DB.DBA.RDF_QUAD AS &quot;s-1-1-t0&quot;
    WHERE /* field equal to URI ref */
        &quot;s-1-1-t0&quot;.&quot;G&quot; = __i2idn ( /* UNAME as sqlval */ __box_flags_tweak ( &#39;http://www.openlinksw.com/schemas/virtrdf#&#39; , 1))
        AND  /* field equal to URI ref */
        &quot;s-1-1-t0&quot;.&quot;P&quot; = __i2idn ( /* UNAME as sqlval */ __box_flags_tweak ( &#39;http://www.openlinksw.com/schemas/virtrdf#qmGraphRange-rvrFixedValue&#39; , 1))
OPTION (QUIETCAST)) AS &quot;s-1-0_rbc&quot;
</pre>
    </div>
<br />
<a name="rdfxmlschemacompat" />
    <h3>14.1.6. Special Cases and XML Schema Compatibility</h3>
<p>We note that since we store numbers as the equivalent SQL binary type, we do not preserve the distinction of byte, boolean etc. These all become integer. If preserving such detail is for some reason important, then storage as a typed string is possible but is not done at present for reasons of compactness and performance.</p>
<br />
<a name="rdfquietcast" />
    <h3>14.1.7. SQL Compiler Support - QUIETCAST option</h3>
<p>The type cast behaviors of SQL and SPARQL are different. SQL will generally signal an error when an automatic cast fails. For example, a string can be compared to a date column if the string can be parsed as a date but otherwise the comparison should signal an error. In SPARQL, such situations are supposed to silently fail. Generally, SPARQL is much more relaxed with respect to data types.</p>
<p>These differences will be specially noticed if actual SQL data is processed with SPARQL via some sort of schema mapping translating references to triples into native tables and columns.</p>
<p>Also, even when dealing with the triple-oriented RDF_QUAD table, there are cases of joining between S and O such that the O can be a heterogeneous set of IRI&#39;s and other data whereas the S is always an IRI. The non-IRI to IRI comparison should not give cast errors but should silently fail. Also, in order to keep queries simple and easily optimizable, it should not be necessary to introduce extra predicates for testing if the O is n IRI before comparing with the S.</p>
<p>Due to these considerations, Virtuoso introduces a SQL statement option called QUIETCAST. When given in the OPTION clause of a SELECT, it switches to silent fail mode for automatic type casting.</p>
<p>The syntax is as follows:</p>
<div>
      <pre class="programlisting">
SELECT ...
FROM .... OPTION (QUIETCAST)
</pre>
    </div>
<p>This option is automatically added by the SPARQL to SQL translator. The scope is the enclosing procedure body.</p>
<br />
<a name="rdfdynamiclocal" />
    <h3>14.1.8. Dynamic Renaming of Local IRI&#39;s</h3>
<p>
    There are cases where it is desirable to have IRI&#39;s in RDF storage
    that will change to reflect a change of the host name of the containing
    store.  This is specifically true of DAV resource metadata for local
    DAV resources.
    Such IRI&#39;s must be stored prefixed with <span class="computeroutput">local:</span>.  
</p>
<p>
    If a user application makes statements with such a URI, then these statements will be returned with local:
    substituted with a prefix taken from the context as described below.
</p>
<p>
    When returning IRI&#39;s from id&#39;s, this prefix is replaced by the Host header of the HTTP request 
    and if not running with HTTP, with the DefaultHost from URIQA.  This behavior is always in effect.
</p>

<p>
    When converting strings to IRI id&#39;s, the <span class="computeroutput">local:</span> prefix may or may not be introduced depending on ini file and other context factors.
    If <a href="databaseadmsrv.html#VIRTINI">DynamicLocal</a> defined in the [URIQA] section of the Virtuoso INI file is on and the host part of the IRI matches the Host header of the HTTP request in context or the DefaultHost if outside of HTTP context, then this is replaced with local: before looking up the IRI ID.  Even if DynamicLocal is not on and the <span class="computeroutput">local:</span> prefix occurs in the IRI string being translated to id, the translating the IRI_ID back to the IRI name will depend on the context as described above.
</p>
<p>
    The effects of DynamicLocal = 1 can be very confusing since many names
    can refer to the exact same thing.  For example, if the DefaultHost is
    dbpedia.org,
    <span class="computeroutput">iri_to_id (&#39;http://dbpedia.org/resource/Paris&#39;) = iri_to_id (&#39;local:///resource/Paris) </span>
    is true and so is  
    <span class="computeroutput">&#39;http://dbpedia.org/resource/Paris&#39; = id_to_iri (iri_to_id (&#39;local://resource/Paris&#39;))</span>
    These hold in a SQL client context, i.e. also when connected through RDF frameworks like Jena or Sesame.
    When running a SPARQL protocol request, the Host: header influences the behavior, likewise when using web interactive SQL in Conductor.
    Also be careful when loading RDF files that may have URI&#39;s corresponding to the local host name.
</p>
<br />
<table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="rdfandsparql.html" title="RDF Data Access and Data Management">Previous</a>
          <br />Contents of RDF Data Access and Data Management</td>
     <td align="center" width="34%">
          <a href="rdfandsparql.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="rdfsparql.html" title="SPARQL">Next</a>
          <br />SPARQL</td>
    </tr>
    </table>
  </div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>