![]() | |
#11
| |||
| |||
|
|
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? |
#12
| |||
| |||
|
|
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.![]() |
| Thread Tools | |
| Display Modes | |
| |