logo       

Re: Join or Caching (??): msg#00092

jakarta.turbine.torque.user

Subject: Re: Join or Caching (??)






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 <saravkrish@xxxxxxx> 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@xxxxxxxxxxxxx
> For additional commands, e-mail: torque-user-help@xxxxxxxxxxxxx
>


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise