Database model: doubly linked list I am not sure if I get this right. I'm designing a database model for use in an application, and I'm stuck at a doubly linked list (model first; there is no code yet).

There's an order. An order has an owner who gives it to someone, an acceptor. The acceptor can decide to divide the order into suborders. He will then become the owner of these suborders and give them to other acceptors. An order can have infinite Suborders, which can also have infinite Suborders and so on. Typical hierarchy. But the (sub-) orders have to be in order (no pun intended), and it would be nice if they could refer to the predecessor and the successor. Predecessor to the first suborder would either be null oder the parent order, successor to the last order either null or the parent order.



What is the best practice in such a case? I feel that the following is a bit... too much clutter (suborders would be a collection).
I'm not sure I understand your question right, but:

If I understand right, this is a tree that has children ordered. Also the creation of children is monotone, that is no children are deleted.
In these cases, in relational databases I used to have:


Id
parent's Id
child order (first child is 1, second 2, etc.)
child count (count of my children, only needed if you want "last child")
acceptor, ...


Key's are ( Id ) &amp; ( parent's ID ; child order ).

In this case:


Previous sibling is ( parent's Id ; child order-1 )
Next sibling is ( parent's Id ; child order+1 )
First child is ( Id ; 1 )
Last child is ( Id ; child count )
Parent id ( parent's Id )


I hope I helped.