Skip to main content
1 of 4
Joe Taras
  • 672
  • 6
  • 21

Instead of Position field you can use a field as LastSongId where you can point the last SongId.

So when you want to change you order you can update only two rows.

The first row: Your song with new order

The second row: The song to point to your changed position song

Your new schema:

+------+------------+----------+
|SongId| PlaylistId |LastSongId|
+------+------------+----------+
|   1  |     10     |    NULL  |
|   2  |     10     |    1     |
|   3  |     10     |    2     | 
|   5  |     10     |    3     | 
|   6  |     11     |    NULL  |
+------+------------+----------+
Joe Taras
  • 672
  • 6
  • 21