[thelist] SQL user-defined order

Matt Slocum matt.slocum at gmail.com
Wed Oct 10 10:52:00 CDT 2007


I want the user to be able to decide the order of a list of
categories. The way I first tried to do it is making an 'order' field
that keeps a numerical order. The problem is that if the last item is
moved to the beginning, then every 'order' value has to be updated.
This is possible, but very inefficient.

My second idea is to make an 'afterID' field that references the ID
that the record is supposed to come after. The problem is that if I do
this, what ID would the first record refer to? It can't be itself,
because there will be another record referring to it. I would like to
maintain referential integrity.

Does anyone have any ideas?



More information about the thelist mailing list