Re: help with nested set

From: Gene Wirchenko <genew_at_ocis.net>
Date: Thu, 16 Apr 2009 16:13:02 -0700
Message-ID: <5tleu456bk52rgbqch16lkaqnjiuivgqij_at_4ax.com>


lawpoop <lawpoop_at_gmail.com> wrote:

>On Apr 13, 9:27 am, paul c <toledobythe..._at_oohay.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.
Received on Fri Apr 17 2009 - 01:13:02 CEST

Original text of this message