Suppose I have some objects, and I want the user to be able to reorder them in any way they wish, say, by dragging them around. So I\'d have
You can user previous Id, every new insertion you set last inserted row ID as previous ID like this,
table, td {
border: .2px solid black
}
ID
NAME
PREV_ID
1
first_item
<null>
2
second_item
1
3
thid_item
2
any time you reordering easily insert with last row id, If you use next id every new insertion you need to update previous one, If you use sort order in any update you have to update multiple rows. Now postgreSQL recursive query available for selecting