[thelist] MySQL/PHP design question : order in a DB table.

Ned Baldessin ned-ml at idsland.com
Wed Jul 23 04:26:06 CDT 2003


Hi,

I'm working on a site that has all it's page structure in a DB table :
it's a hierarchy of parents and children that form a tree structure.

I'm trying to find the best design to be able to easily change the order
in which the siblings are outputted. I need to be able to set an
arbitrary order, for example, change this

    1 Aaa
    2 Bbb
    3 Ccc

into this :

    1 Bbb
    2 Aaa
    3 Ccc

The best I could think off is to create a column called 'ordered', and
put a number in it for each row : 1, 2, 3, etc.
The problem is each time I want to change the order (increment or
decrement the number), I have to check all the other siblings to see if
there is any overlap. 

Does anyone have a more elegant and simple design ?
Thanks. 


More information about the thelist mailing list