From torque-user-return-5526-apmail-db-torque-user-archive=db.apache.org@db.apache.org Tue Nov 16 11:28:36 2004 Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 72699 invoked from network); 16 Nov 2004 11:28:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 16 Nov 2004 11:28:36 -0000 Received: (qmail 83392 invoked by uid 500); 16 Nov 2004 11:28:33 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 83376 invoked by uid 500); 16 Nov 2004 11:28:32 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Users List" Reply-To: "Apache Torque Users List" Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 83363 invoked by uid 99); 16 Nov 2004 11:28:32 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [194.175.229.106] (HELO mail.seitenbau.net) (194.175.229.106) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 16 Nov 2004 03:28:28 -0800 Received: from [195.127.188.18] (helo=www.seitenbau.net) by mail.seitenbau.net with esmtp (Exim 4.30) id 1CU1VO-0002vS-47 for torque-user@db.apache.org; Tue, 16 Nov 2004 12:28:14 +0100 In-Reply-To: <1100587643.4196.19.camel@r2d2> Subject: Re: Join or Caching (??) To: "Apache Torque Users List" X-Mailer: Lotus Notes Release 6.0 September 26, 2002 Message-ID: From: Thomas Fischer Date: Tue, 16 Nov 2004 12:28:13 +0100 X-MIMETrack: Serialize by Router on www/seitenbau(Release 6.5.1|January 21, 2004) at 16.11.2004 12:28:13 PM MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-Scan-Signature: 6a28f7d6367dae4b0428f114a37fc2a7 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi Sarav, I am not sure how you structured your tree. I presume you use the parent as a foreign key. Then, I see no way how you can read in the complete tree with a join because you have the one-to-many relation of B with itself. Therefore, the depth of your tree is not limited and also the number of joins needed is not limited. It may work if you let every B and C also have a reference to its A parent, but of course this is a redundancy which may complicate updates and lead to inconsistency. It might also be worth while to check alternative tree models. See e.g. (materialized path) http://www.dbazine.com/tropashko4.shtml (nested set) http://www.intelligententerprise.com/001020/celko.jhtml I have no idea about caching, cannot help you there. Thomas Saravana Krishnan schrieb am 16.11.2004 07:47:23: > Hi, > > I have 3 tables A, B and C. A has a one-to-many relationship with B > _and_ C. B has a one-to-many relationship with itself _and_ C. > > For example (ASCII art tree - fixed width font will help) the following > is a valid tree that I'm trying to represent with the tables A, B and C- > > A > | > +---+---+ > | | | > B B C > | > +---+ > | | > B C > | > +-+ > | | > C C > > As of now, I use A.getBs(), A.getCs(), B.getBs() (I wrote this in > B.java) and B.getCs() functions to get the tree recursively and create > another object tree consisting of objects XA, XB and XC which are direct > mappings of A, B and C. So for a single tree, Torque does several > queries to read in all the nodes. Is there a way to read in the whole > tree? May be using some kinda JOIN? > > Another idea I had, which assumes Torque does some kinda caching is, > relate all the nodes of a single tree to a particular TreeObj. I can > then do something like Tree.getAs(), Tree.getBs() and Tree.getCs(). Then > I will do the same recursive querying as mentioned in the above para and > the caching will limit the total queries for a tree to 3 (one each for > all the As, Bs and Cs) instead of n (where n is the number of non-leaf > nodes). So, does torque do any kind of caching? > > Thanks in advance, > Sarav > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org > For additional commands, e-mail: torque-user-help@db.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org For additional commands, e-mail: torque-user-help@db.apache.org