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 type http://tucana.org/tucana#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 tucanav 'http://tucana.org/tucana/view#'> <!ENTITY server 'rmi://mysite.com/server1'> ]> <rdf:RDF xml:lang="en" xmlns:rdf="&rdf;" xmlns:tucanav="&tucanav;"> <tucanav:Union rdf:about="http://tucana.org/tucana/view" tucanav:enabled="true"> <tucanav:model rdf:resource="&server;#model1"/> <tucanav:expr> <tucanav:Intersection> <tucanav:model rdf:resource="&server;#model2"/> <tucanav:model rdf:resource="&server;#model3"/> </tucanav:Intersection> </tucanav:expr> <tucanav:expr> <tucanav:Intersection> <tucanav:model rdf:resource="&server;#model4"/> <tucanav:model rdf:resource="&server;#model5"/> </tucanav:Intersection> </tucanav:expr> </tucanav:Union> </rdf:RDF>
Which generates the following triples:
http://tucana.org/tucana/view http://tucana.org/tucana/view#enabled 'true' http://tucana.org/tucana/view http://tucana.org/tucana/view#expr rmi://mysite.com/server1#node32 http://tucana.org/tucana/view http://tucana.org/tucana/view#expr rmi://mysite.com/server1#node35 http://tucana.org/tucana/view http://tucana.org/tucana/view#model rmi://mysite.com/server1#model1 http://tucana.org/tucana/view http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://tucana.org/tucana/view#Union rmi://mysite.com/server1#node32 http://tucana.org/tucana/view#model rmi://mysite.com/server1#model2 rmi://mysite.com/server1#node32 http://tucana.org/tucana/view#model rmi://mysite.com/server1#model3 rmi://mysite.com/server1#node32 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://tucana.org/tucana/view#Intersection rmi://mysite.com/server1#node35 http://tucana.org/tucana/view#model rmi://mysite.com/server1#model4 rmi://mysite.com/server1#node35 http://tucana.org/tucana/view#model rmi://mysite.com/server1#model5 rmi://mysite.com/server1#node35 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://tucana.org/tucana/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:
- Views may not be used for the
in clause within a where clause of a select command. - Mutually referential views and reference loops are not detected.
|