You can still have a PK and index your other column. No different than searching a user unique name (Handle).
non numeric primary key
Just a curiosity of mine about using non-numeric column as primary key (PK) so there's no code to show nor actual database table
Let's say I have a table of computers, each of those computers have unique code in real life so I make the table like this:
id -> smallint (auto increment)
uid -> varchar (8), unique (that computer's irl unique id)
room -> varchar (32)
etc.
and then I have a table of employee_computer like this:
employee_id -> int
computer_id -> smallint/varchar(?)
active -> bit
I know I could use the uid as pk and use varchar with on update cascade on the employee_computer,
but should I do that?
I know that most of the time, using number for pk is better due to fast search time and could easily set unique by using auto-increment, but having id and uid just feel redundant,
especially when searching what computer is being used by who, thing will go
employee.name->employee.id->employee_computer->computer.id->computer.uid
if I use the uid as PK, it will shorten the steps to
employee.name->employee.id->employee_computer->computer.id(varchar)
Please or to participate in this conversation.