Forum Moderators: open

Message Too Old, No Replies

sub groups of sub groups table structure

i know how to structure a table for one sub group... but..

         

richgran

11:34 pm on Nov 15, 2005 (gmt 0)

10+ Year Member



all
how would i structure my tables if multiple sub groups are needed. ie sub groups of sub groups?

as you can tell i'm not greatly experienced. i have however built databases with parentgroup and groups (multiple) relating back to parentgroup through the id all in one table.

doing it this way i am limited to two levels ie groups (parentgroup) and groups (subgroup).

i need eg groups (parentgroup) and groups (subgroup) and subgroup (sub groups of groups).

is this clear! i'm not questioning any of you guys intelligence! just mine!

thanks in advance

Dijkgraaf

1:42 am on Nov 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this sort of what you have?
You have a single table called group with collumns
groupid
groupname
parentgroupid
For those groups that are the top level, parentgroupid is null, for all others they point to their parent.
E.g.
groupid,groupname,parentgroupid
1,Food,NULL
2,Vegtables,1
3,Fruit,1
4,Carrot,2
5,Pea,2
6,Apple,3

Food is the top level parentgroup
Vegtables and Fruit are subgroups of the parentgroup
Carrot,Pea,Apple are subgroups of subgroups.

You can basically have as many levels deep as you like, the fun bit though as building the code that uses that.

richgran

2:12 am on Nov 16, 2005 (gmt 0)

10+ Year Member



Food is the top level parentgroup
Vegtables and Fruit are subgroups of the parentgroup
Carrot,Pea,Apple are subgroups of subgroups.

the fun bit though as building the code that uses that.

that is exactly it! i was told that one could only have subgroups of parentgroup with this table structure. i was led astray!

your last point about bulding the queries/code is what bothers me!

thanks heaps (kia ora!)

Dijkgraaf

4:02 am on Nov 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're welcome :-)
If you describe here which database and scripting language you are using, what you are trying to achieve and what you have tried (with code snippets) so far and what problems you are having, then I'm sure somebody will be able to help.

P.S. I take it from your Kia Ora that you are an New Zealander? Kia Ora back at you from Auckland.

richgran

10:46 pm on Nov 16, 2005 (gmt 0)

10+ Year Member



i certainly will post to this forum for future help... its great! i'm using classic asp at present with a view to moving to asp.net (as you would!)

i'm a kiwi, moved over to perth west oz about a year ago... doing a bit of freelance web dev over here.

kia ora twice