[redland] Best way to use API when using Bags?

Dave Beckett dave.beckett at bristol.ac.uk
Tue Aug 20 12:25:10 BST 2002


>>>Seth Ladd said:
> Hello,
> 
> We're rolling along with our work with redland.  We have a model that 
> contains Bags of resources.  I think we're kinda missing something in 
> the API to efficiently handling Bags.

Yeah, they are a pain.

> We have a model something like (excuse my nTriples) :
> 
> _:group _:members _:A0 .
> _:A0 rdf:type rdf:Bag .
> _:A0 rdf:li <http://member/uri> .
> _:A0 rdf:li <http://member/uri> .
> _:A0 rdf:li <http://member/uri> .

That should be
 _:A0 rdf:_1 <http://member/uri> .
 _:A0 rdf:_2 <http://member/uri> .
 _:A0 rdf:_3 <http://member/uri> .

(no order implied 'cos of rdf:Bag)

> 
> I'm trying to say that an object group has members which is a Bag.  That 
> bag has resources that are people.
> 
> we're trying to efficiently say "Get all groups that person X is a 
> member of".  If Group had a property hasMember then this would be easy, 
> but because we made a Bag of members, this seems to be hard to find out 
> without a lot of walking through the tree.

I'd suggest just using such a property off the group resource and
ignoring bags.

You might find something useful from the DC terms namespace at
http://dublincore.org/usage/terms/dc/current-elements/

such as dcterms:isPartOf

> Does anyone have any suggestions on how to use the API to answer a 
> question like the above?  We can do something like:
> 
> get all statements thta have person X as object
> check if type of subject of those statements are rdf:Bag
> get statements where predicate is members and object is the bag itself
> get the subject of that statement, and check its type == group
> 
> Any tips and suggestions would be greatly appreciated.

If I had the time, I'd have added an API like mozillas, where it
records for each container type, a (hidden) property holding the
next rdf:li count, so you can ask questions about 'all members'
of a container and do other container ops.

See IDL interface:
   http://lxr.mozilla.org/mozilla/source/rdf/base/idl/nsIRDFContainer.idl
and implementation:
   http://lxr.mozilla.org/mozilla/source/rdf/base/src/nsRDFContainer.cpp

[[
    2. The RDF:nextVal property on the container is an
       implementation-level hack that is used to quickly compute the
       next value for appending to the container. It will no doubt
       become royally screwed up in the case of aggregation.
  
    3. The RDF:nextVal property is also used to retrieve the count of
       elements in the container.
]]

Dave







More information about the redland-dev mailing list