Gossamer Forum
Quote Reply
cat_root
What is the meaning of the field cat_root in the Category table? What are it's values supposed to be?

Thanks for any help.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] cat_root In reply to
Hi,

The category root is used to maintain the category tree (referenced in gforum_Category_tree), and stores the id of the parent category. It get's auto updated upon any changes/inserts.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] cat_root In reply to
Thanks for your answer.

So, basically cat_root is the same as cat_id_fk? Or is there a difference?

I am asking because I am in the process of writing a script that makes categories and forums automatically, and I need to ensure the integrity of the data.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] cat_root In reply to
cat_root is the father of the category, therefore it's also a cat_id_fk.

Adrian
Quote Reply
Re: [brewt] cat_root In reply to
I don't really understand.

There are two fields, "cat_root" and "cat_id_fk" in the "Category" table. As far as I can see, they store precisely the same data. Is there a reason for this? Or am I missing something?

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] cat_root In reply to
umm... okay I screwed that all up. I've gotten myself all confused now Smile Plus it's 3am now, so I think i'll just let Jason answer this. *yawn*

Adrian
Quote Reply
Re: [brewt] cat_root In reply to
Ok, thanks anyway. I'll wait for Jason's answer.

You should go and get some sleep....

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [brewt] cat_root In reply to
What's up you GT guys? Is Vancouver that buzzing that you just never sleep?! :-)

- wil
Quote Reply
Re: [yogi] cat_root In reply to
>>There are two fields, "cat_root" and "cat_id_fk" in the "Category" table. <<

Which version is this?

Im using 1.1.1 and don't see cat_root
Quote Reply
Re: [Paul] cat_root In reply to
This is something new in version 1.1.3. It has got to do with a new module in the GT library (as far as I see), called GT::SQL::Tree. Seems to be very handy...

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] cat_root In reply to
Category.cat_root is the cat_id of the root category to which a category belongs. For comparison, Category.cat_root is to categories what Post.post_root_id is to posts.

For examples sake, let's say we have a category structure like this:

Code:
A
B
C
D
E
F
G
H


(Let's assume for the example that the category ID's are A-1, B-2, C-3, etc.) Now, cat_root will be '0' for root categories - A, F, and G in this example. B, C, D, and E have A as their root category, so their 'cat_root' value will be 1 - the cat_id of A. For B and D, the cat_id_fk value will have the same value since their father category and root category are one and the same. C and E will have 2 and 4 as their father_id_fk values, respectively, and 1 as the cat_root values. H will have both cat_id_fk and cat_root of '7'. cat_depth is easy to see here - A, F, and G have depth of 0; B, D, and H have cat_depth = 1, and C and E have a depth of 2.



In GForum 1.1.2 we moved the nested category handling from a GForum-specific model into our new generic SQL tree handling module, GT::SQL::Tree. We also moved the Post table over to use this new generic tree format (which is why the 'Ancestor' table became 'Post_tree' - there is also a 'Category_tree'). Typically, you shouldn't ever need to worry about the cat_root field - internally, when an update alters cat_id_fk column, the cat_root and cat_depth columns are automatically updated.

This tree module will be useful in other areas as well - I'm trying to convince Adrian to use it for nested folders in GMail. Wink

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] cat_root In reply to
Thanks for you answer. It makes perfect sense.

In Reply To:
Typically, you shouldn't ever need to worry about the cat_root field - internally, when an update alters cat_id_fk column, the cat_root and cat_depth columns are automatically updated.
If I create a new category (through my own script), it seems like I have to worry about passing in the cat_root value and the cat_depth columns. The cat_depth is no problem, and the cat_root I can, according to you explanations, just copy from the cat_root of the father category (i.e. the category in cat_if_fk).

In Reply To:
This tree module will be useful in other areas as well - I'm trying to convince Adrian to use it for nested folders in GMail. Wink

Will it also be used in Links SQL? That would make sense, too.

Thanks a lot again.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] cat_root In reply to
In Reply To:
Will it also be used in Links SQL? That would make sense, too.
Will it be? Probably, eventually. Wink I can't tell you when though.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com