Views
Views are special models made up of one or more models or views. The advantages of views include:
- Security permissions are defined and maintained at the nested model and view level.
- Statements can be grouped within logical models for re-use and maintenance. For example, schemas can be maintained in a single model and shared with multiple views.
- You can define model hierarchies. For example, views can support nested views.
- There is an abstraction layer for the end-user application. That is, the application layer may only be concerned about a single view.
- Views are defined in RDF and can be extended to support application specific requirements.
Creating Views
You can create views by:
- Using the iTQL
create
command, creating a model of typehttp://mulgara.org/mulgara#ViewModel
. This creates the view, plus a view definition model. - Loading RDF that represents the set of models for the view, into the view definition model. For example,
rmi://mysite.com/server1?def#view1
.
Views are a symbolic model expression equivalent to an iTQLTM from
clause. Querying a view queries all of the models to which the view refers. When the URI of a view occurs in the from
clause of a select
command, the view's model expression is substituted in place of the view URI when the query is processed.
Any modifications applied to the view (by using insert
, delete
or load
commands, for example) only affect the view's definition and have no effect on the models to which the view refers.
Since a view is a symbolic representation of a combination of models, any modifications to models to which the view refers are visible immediately via the view.
Here is an RDF example, that when loaded into the view definition model, defines the set of models for a view:
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<!ENTITY mulgarav 'http://mulgara.org/mulgara/view#'>
<!ENTITY server 'rmi://mysite.com/server1'>
]>
<rdf:RDF xml:lang="en"
xmlns:rdf="&rdf;"
xmlns:mulgarav="&mulgarav;">
<mulgarav:Union rdf:about="http://mulgara.org/mulgara/view"
mulgarav:enabled="true">
<mulgarav:model rdf:resource="&server;#model1"/>
<mulgarav:expr>
<mulgarav:Intersection>
<mulgarav:model rdf:resource="&server;#model2"/>
<mulgarav:model rdf:resource="&server;#model3"/>
</mulgarav:Intersection>
</mulgarav:expr>
<mulgarav:expr>
<mulgarav:Intersection>
<mulgarav:model rdf:resource="&server;#model4"/>
<mulgarav:model rdf:resource="&server;#model5"/>
</mulgarav:Intersection>
</mulgarav:expr>
</mulgarav:Union>
</rdf:RDF>
Which generates the following triples:
http://mulgara.org/mulgara/view http://mulgara.org/mulgara/view#enabled 'true'
http://mulgara.org/mulgara/view http://mulgara.org/mulgara/view#expr rmi://mysite.com/server1#node32
http://mulgara.org/mulgara/view http://mulgara.org/mulgara/view#expr rmi://mysite.com/server1#node35
http://mulgara.org/mulgara/view http://mulgara.org/mulgara/view#model rmi://mysite.com/server1#model1
http://mulgara.org/mulgara/view http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://mulgara.org/mulgara/view#Union
rmi://mysite.com/server1#node32 http://mulgara.org/mulgara/view#model rmi://mysite.com/server1#model2
rmi://mysite.com/server1#node32 http://mulgara.org/mulgara/view#model rmi://mysite.com/server1#model3
rmi://mysite.com/server1#node32 http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://mulgara.org/mulgara/view#Intersection
rmi://mysite.com/server1#node35 http://mulgara.org/mulgara/view#model rmi://mysite.com/server1#model4
rmi://mysite.com/server1#node35 http://mulgara.org/mulgara/view#model rmi://mysite.com/server1#model5
rmi://mysite.com/server1#node35 http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://mulgara.org/mulgara/view#Intersection
The RDF is equivalent to the following from
clause:
... from <rmi://mysite.com/server1#model1> or
(<rmi://mysite.com/server1#model2> and
<rmi://mysite.com/server1#model3>) or
(<rmi://mysite.com/server1#model4> and
<rmi://somewhere.com/server1#model5>) ...
If the above RDF is loaded into the view definition model, rmi://mysite.com/server1?def#view1
, then the following from
clause is equivalent to the preceding one:
... from <rmi://mysite.com/server1#view1> ...
Querying View Definitions
You can query the definition of a view by adding ?def
to the view name. For example:
select $s $p $o
from <rmi://mysite.com/server1?def#view1>
where $s $p $o;
The ?def
query string can be used in the model URIs that are referenced by a view definition. That is, views can reference other views.
Note - Since views can reference other views, make sure you don't define views that reference each other.
Limitations of Views
The current limitations of views are as follows: