Should primary keys of MySQL tables be exposed?

后端 未结 6 1384
天涯浪人
天涯浪人 2021-01-02 10:38

I have a number of MySQL tables describing models such as \"User\", \"Business\" etc. Should the primary keys of these tables ever be exposed to the client-side? I am asking

6条回答
  •  自闭症患者
    2021-01-02 11:21

    There would be not much harm in exposing it in general. People would be able to guess which records were created later by having a higher id.

    But you would need to have any required security in place. If the users changes the id, are you already running checks to see if they are allowed to view that data? If you have some other method of looking up the data, it will probably be harder to guess the correct values. But you would have to ensure they are distinct, and the data you use might also be guessable.

提交回复
热议问题