RE: Query across multiple models

Andy is right with the Jena MultiUnion
although i never used it and programmed the same thing myself (I thought
that Jena has to have something like it but didn't find it because the
class is not good documented and I couldn't guess the name right when I
looked for it - Or is it a new feature in Jena 2.0?)
know from my experience I know that this works very fine.
You don't have to union the models by adding all data into a big model, 
you just have to pass the query to all submodels and gather all result
triples in a single result.
I have provided a "optimized" solution (what andy talks about) for this
problem in my gnowsis framework for Personal Information Management. 
The center of my work is a "data hub" that is a jena model. the DataHub
hides a lot of other data sources inside. It answers queries by
forwarding them to the data inside. I integrated Jena Models as
datasources and also Adapters. By Adapters i have made available the
filesystem data as RDF graph and Microsoft Outlook as RDF graph, also
MP3 file information.
There you come to the "optimization" problem based on application
To decide which adapter has to be contacted with a query (drilled down
to a triplematch find()), I have a "Registry" of adapters. Each adapter
is registered to handle certain Resource URLs. 
F.e. I can scan a file url:
and see that it is of scheme "file", on "localhost", in the file-share
"multimedia" and has ending "mp3".
I have registered a "FileAdapter" that can now create triples about this
resource (<file> <hasfilesize> <filesize>).
There are models that are always queried, without regard to the url.
these models are "integrating" models like a PIM or a database. It is
good to store bidirectional links in central stores, these stores are
then always queried.
So the query goes not to all datasources (there will be nothing about
the file url to be known in Microsoft Outlook) but to a selection.
This approach has some flaws, that I am aware of but it is better than
nothing or the plain MultiUnion.
Another good reason for the URL-parsing and source determination
approach, and this one is serious, is that all webservers in the world
work that way and the WWW has proven to work, so this approach scales
very good. think of an apache that checks out the ".php" endings on
files to query mod_php. 
Mind that this approach is based on my philosophy of "everything needs
to be identified by an URL" 
The approach is published in my thesis at
There will be an open-source alpha-alpha release of gnowsis at the end
of January (probably 30th :-)
Leo Sauermann, CTO

-----Original Message-----
[] On Behalf Of Bob MacGregor
Sent: Friday, January 09, 2004 6:45 PM
Subject: Query across multiple models

<offshoot of a tiny Jena thread>

The fact that we can't query against a set of models reflects a problem
with RDF that can be expected to grow much more serious over time.
Basically, anyone who is doing serious RDF work is going to have
a lot of models, and most queries will run against multiple models.

What's needed to begin with is a formal means for defining the
equivalent of 
(dynamic) "union"
models.  The current Jena union is static (I think).  If   U represents
the union
of A and B, and updates are made to A or B, those updates are not
in U.  This is not acceptable in the long run.  

There are, of course, many ways to define union.  The "import ontology"
in OWL is a somewhat badly-conceived means for doing so.  So adding this
is something that would probably take a committee quite a while to hash

Right now, there is a lot of bookkeeping that has been thrust on users
the boundaries of the RDF spec cut off prematurely.  RDF has nothing
resembling union, and it should have.  Until it does, RDF-based
applications will not scale
gracefully to multiple model situations.

Cheers, Bob

At 01:54 PM 1/8/2004, Seaborne, Andy wrote:


You can create a union model and ask a query of that model: this will
the query over both of the submodels.

There is no optimization done by the union model: because it does not
in which model properties might be, it ask each model for each part of
query pattern.  If both the models are in the same database, then,
currently, this would not be optimized to pass a single query down that
work against both models.  It could be but as there are different
possibilities for database layout, the number of possible optimizations
schemes grows.

Such optimizations are possible with the architecture, they just aren't
implemented.  You could write a specialization of the union model that
optimized queries base on application-specific knowledge of where
information is to be found.


> ----Original Message----
> From: andreasharth <>
> Date: 8 January 2004 19:17
> Hi,
> I want to have a (RDQL) query that spans two or more models.  For
> example, get dc:title for <> from modelA and
> get dc:description for the same URI from modelB.  The query I have in
> mind is more complicated, but that's basically the functionality I am
> looking for.    
> What would be the best way to query across multiple models in Jena2?
> Thanks,
> Andreas.
> Yahoo! Groups Links
> To visit your group on the web, go to: 
> To unsubscribe from this group, send an email to: 
> Your use of Yahoo! Groups is subject to: 


Yahoo! Groups Links 

*	To visit your group on the web, go to: 



*	To unsubscribe from this group, send an email to: 



*	Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <> . 

Robert MacGregor
Senior Project Leader 
Phone: 310/448-8423, Fax:  310/822-6592
Mobile: 310/251-8488

USC Information Sciences Institute 
4676 Admiralty Way, Marina del Rey, CA 90292 

Received on Saturday, 10 January 2004 04:55:18 UTC