dbTalk Databases Forums  

help with nested set

comp.databases.theory comp.databases.theory


Discuss help with nested set in the comp.databases.theory forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: help with nested set - 04-16-2009 , 06:13 PM






lawpoop <lawpoop (AT) gmail (DOT) com> wrote:

Quote:
On Apr 13, 9:27*am, paul c <toledobythe... (AT) oohay (DOT) ac> wrote:
lawpoop wrote:

...

Suppose I had this adjacency list:

id *client_id parent_id level
1 * * * 1 * * * *NULL * * *Corporate
2 * * * 1 * * * * *1 * * * Franchise 1
4 * * * 1 * * * * *1 * * * Eastern Region
5 * * * 1 * * * * *4 * * * New York District
...

Can't comment on product techniques but if this were a 'table', I'd
wonder how a client can be its own parent. *I would have thought some
constraint would prevent that.

Are you asking why all of these example rows have a value for the
client_id? Are you saying it should look like this? :

id client_id parent_id level
1 1 NULL Corporate
2 NULL 1 Franchise 1
4 NULL 1 Eastern Region
5 NULL 4 New York District

MySQL check constraints are somewhat limited; what would you suggest?
Remove the null.

Entity
id *client_id level
1 * * * 1 * * *Corporate
2 * * * 1 * * *Franchise 1
4 * * * 1 * * *Eastern Region
5 * * * 1 * * *New York District

ParentEntity
id parent_id
2 1
4 1
5 4

Since Corporate does not have a parent, it does not have a row
in the ParentEntity table.

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
  #12  
Old   
lawpoop
 
Posts: n/a

Default Re: help with nested set - 04-20-2009 , 12:20 PM






On Apr 16, 4:13*pm, Gene Wirchenko <ge... (AT) ocis (DOT) net> wrote:

Quote:
Entity
id *client_id *level
1 * * * 1 * * *Corporate
2 * * * 1 * * *Franchise 1
4 * * * 1 * * *Eastern Region
5 * * * 1 * * *New York District

ParentEntity
id *parent_id
2 * * *1
4 * * *1
5 * * *4

* * * Since Corporate does not have a parent, it does not have a row
in the ParentEntity table.
Clever.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.