In a specific table, I have an integer field SortOrder that tells my page in which order to display the data. There are data sets in this field (based on the CategoryID field), and each set will have its own order. Users can add / delete / update entries in this table.
My question is the best way to manage this SortOrder field? I would like to βreseedβ it every time a record is deleted or updated. For this, should I use a trigger? Or should my code handle it and control repetition?
What I used is to use only odd numbers in the SortOrder field, so by changing the order I would add or subtract 3 from the current value of the changed item and then reload (order the items again using an odd number of indices). Also I used reseed after every insert or delete.
, , . , , , . , , . , , , . , - . ( , , , . , ORDER BY. .)
Source: https://habr.com/ru/post/1723712/More articles:Get the source code from a precompiled ASP.NET website? - c #Nested Lambdas in Python - closuresThe default log level for the Zend Framework is phpWhat is the value of interfaces? - interfaceWPF object sends itself as a MultiBinding path - data-bindingRails category category navigation with tags - ruby-on-railsis an abstract interface type class? - c #Determining user intent in a multi-user multi-touch application - c #Python - simple algorithmic task in lists (standard question for interview) - pythonSimple Lisp Question - lispAll Articles