Forum OpenACS Development: Objects data model

Collapse
Posted by Eduardo Santos on
Hy guys

Well, I'm having a little trouble right now. I'm working in the user-tracking package, where I want to show the community_id of the most visited objects. So, what I have to do is find some relationship between the object_id and the community_id.

Looking over the tables, I foud the context_id in the acs_objects. I thought that the context_id should be the same as the package_id of the community, but it's not, and I can't find any other relations about them. Can anybody tell me what's the relation about the object's context_id and the community's package_id? How can I build a query that returns me the community_id for the given object_id?

Collapse
2: Re: Objects data model (response to 1)
Posted by Malte Sussdorff on
With OpenACS 5.3, acs-objects.package_id should contain the package_id of the object, if all your applications have been rewriten to actually store it (or if they are using the content repository TCL API).

You could then write a quick function to check the package_id in acs-objects and see to which community the package_id belongs to.

There is no direct connection between context_id and package_id or community_id.

Collapse
3: Re: Objects data model (response to 2)
Posted by Eduardo Santos on
Well, I tried to do so, but it seems like the package_id for the objects is not the same package_id for a community. What I did to solve this issue is a little bit different: I am "walking up" the table. I got the context_id and put it in the object_id. Then I got the context_id for the new object and put it in the object_id. It's like climbing up the stairs, until I find the object_type like dotlrn_community.

The problem here is about the performance. I'm doing recursive searchs in a huge table like acs_objects, and this is not a nice thing to do. What I could find out is that I can improve the performance of my query using the tree_sortkey. However, I found another problem here: it just doesn't work for some objects. For forums it works, but for other objects, like file-storage folders it does not work. It seems like the tree_sortkey of the file-storage object is related to its parent folder, but it never gets to the community. So, I'm out of ideas to improve the performance. Any idea?

Collapse
4: Re: Objects data model (response to 1)
Posted by Dave Bauer on
https://openacs.org/api-doc/proc-view?proc=site%5fnode%3a%3aclosest%5fancestor%5fpackage

Take the package_id of the object, find the site_node for it, then use that tcl procedure to search the site map. The site map is an array stored in ram so it can peform the search much more quickly than querying each step from the database.

Also you should understand how to do a tree query in your database. See Hierarchal Data https://openacs.org/doc/openacs-5-0-4/tutorial-advanced.html