The simple method I could think of is to store some kind of a 'rank' attribute in the table and query by sorting on that attribute.But in this method inserting/modifying a record with a rank becomes a costly operation. Specifically, I am looking to implement the table using Amazon's Simple DB.If multiple tables are specified, they are implicitly inner joined.Lovefield supports only inner join and left outer join, which can also be done using .The select query builder is created by calling One important concept is to treat the returned results of select queries as read-only and do not modify it.
I am expecting the ranks to change constantly and new records being inserted constantly.
Another solution I've seen is using decimal numbers and just sticking items in the gaps between them, which seems like the best solution so far, but I'm sure there has to be a better way. is exact, but the right sequence of moves will run you out of precision and your implementation will break badly.
I would say a typical list would contain up to about 20 or so items, and I will probably limit it to 50. Limiting moves to single ups and downs makes the whole operation very easy.
The re-ordering would be using drag and drop and will probably be done in batches to prevent race conditions and such from the ajax requests. For a list of sequentially-numbered items, you can move an item up by decrementing its position and incrementing the position number of whatever the previous decrement came up with.
(In other words, item ) are a little trickier and have to be done differently depending on whether the new position is above or below the old one.