Click here to Skip to main content
15,662,459 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to know if user know and treate with primary key in table is this true? in my case each management has (a unique code, Not changing)  and user should know it and search in system by it is there any problem if i set this code as a primary key related with security or any other problem

What I have tried:

i make a lot of search and not found any one mention to if there is security problem or not
Updated 21-Aug-21 22:39pm
Richard MacCutchan 22-Aug-21 3:37am    
The user should not need to know anything about the database. The UI should present options and accepts requests in native language. What happens behind the scenes is something they have no control over.

1 solution

I prefer to use multiple keys. The primary key is always a surrogate (or synthetic) key which guarantees uniqueness bot holds no other meaning. This also means that no-one needs to know the value of the surrogate key except the system.

The other keys are natural (or business) keys. These are based on the values entered by the user and they can be used for searching the data. Natural keys enforce uniqueness on a logical level. For example same email cannot be entered twice etc.

To learn more about these concepts, have a look at
- Surrogate key - Wikipedia[^]
- Natural key - Wikipedia[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900