Suppose I have a table that stores a list of sections of the site. If you need to change the order of these sections when displaying the menu (for example, from "home | contacts | news" do "home | news | contacts"), is it worth changing the Primary key values ​​or is it a bad practice and it is better to create a new field and change its values?

  • Why change the article metami? and most importantly, what kind of places? Where are these seats? - Mikhail Vaysman
  • 3
    Primary key is inviolable. To determine their order come up with other criteria. - PinkTux
  • @MikhailVaysman under "to change articles in places" I meant "to change their order" - Semushin Sergey
  • @ SemushinSergey order where? - Mikhail Vaysman
  • four
    There is nothing to edit. and so it is clear - primari cannot be changed and the sorting order should not depend on it exactly. need a custom sort - make a separate field. and it is desirable not 1,2,3 and it is not convenient to insert it into the middle - Mike

1 answer 1

As already suggested in the comments,
"Primary key is inviolable" (c) @PinkTux
and
"Primari cannot be changed and the sorting order should not depend on it exactly" (c) @Mike

Thanks for answers!

  • 2
    You need to understand what a Primary Key is. You can change it, but not very profitable. Usually it is referenced by many other records from their different tables. If you change it, then you need to change the entire database. But if suddenly a table without connections (never encountered this), then you can make a variable primary key. - Sergey