Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am designing a employee information database. I usually keep an auto incremented ID primary key for each table. But there is also a unique employeeID field. Now problem is i want to know choosing a auto incremented primary key is better or choosing a varchar , that the user will give input? This primary key has been used as foreign key in many other tables. I am using MSSQL severe 2008. Please help......
Posted

autoincrement primary key is better (searching for int is faster than searching for a varchar). This key can be used in other tables in combination with FK and index.
The autoincrement knows how to keep the id unique.
 
Share this answer
 
Use a integer column as a key. It should not be a user input. Just because of curiosity, why would user provide input for EmployeeId?
 
Share this answer
 
Comments
Ehtesam Ahmed 9-Aug-11 7:18am    
suppose a roll number of student. when inserting a student info the user have to give input the roll which is the primary key of the table. Is there any problem with that?????
dan!sh 9-Aug-11 7:21am    
The column name looks as if it is the primary key for the table. Primary should be system generated. I think you must add another integer column to act as primary key.

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