Should I run user identifiers from 1 to 1000 in the database? What for?

Should I use large numbers for user identifiers in the database? Are there any advantages when running user_id from 1000 (from a project with 9000 users) or 10000 for more ...?

+4
source share
3 answers

The advantage of running user IDs with 1000 (even if you have less than 9,000 identifiers) is that they will all have the same number of digits, so files, for example, with suffixes with UIDs will be sorted in numerical order automatically, even if the sorter uses only alphabetic numbering. And you don't need to fill in the numbers with leading zeros to get there.

Conversely, if you have only 1000 users, numbers starting with 1,000,000,000 look a little silly: 1,000,000,001, then 1,000,000,002, etc.

Therefore, for many purposes, it does not matter what you do. An unambiguous number of digits has some advantages, and therefore a value other than zero or one is often used as a starting point.

+3
source

I know this answer comes late, but there is still something to add, imo:

1) The approach of using 1000 as the initial identifier may be advantageous, for example. if you do not want it to be clear how many users you have (if you make the identifier visible somewhere in the url or sth) and therefore (or optionally)

2) this can be useful if you want identifiers to be more difficult to guess, because usually the first identifiers belong to administrators or moderators, so if you run any identifier to run (for example, 1421), you can simply add another security setting to your db ...

+2
source

actually. I would just start with 1. If you need to add something to the material, there is no problem with negative numbers, so you can simply insert and manually specify id. In my company, we start all users in one, automatic increment, and our global administrator is ID 0.

+1
source

Source: https://habr.com/ru/post/1299758/


All Articles