Suppose I have a table of users. Something like:
ID integer,
USER text,
POSITION integer
My db tuples can be:
(1, "user1", 1);
(2, "user2", 2);
(3, "user3", 3);
My app lists all users and it has the possibility to reorder it. For example: You can make user3 go before user2.
(1, "user1", 1);
(2, "user2", 3);
(3, "user3", 2);
Also you might want to move someone to the first place. For example: if you have ...
(1, "user1", 1);
(2, "user2", 2);
(3, "user3", 3);
... and you move user3 to the first place, the db should be:
(1, "user1", 2);
(2, "user2", 3);
(3, "user3", 1);
Is using a POSITION
column the correct approach?
Is there a way to get this done without too many hits to the db?