I’m just wondering what the optimal solution is here.
Say I have a normalized database. The primary key of the whole system is a varchar. What I’m wondering is should I relate this varchar to an int for normalization or leave it? It’s simpler to leave as a varchar, but it might be more optimal
For instance I can have
People ====================== name varchar(10) DoB DateTime Height int Phone_Number ====================== name varchar(10) number varchar(15)
Or I could have
People ====================== id int Identity name varchar(10) DoB DateTime Height int Phone_Number ====================== id int number varchar(15)
Add several other one-to-many relationships of course.
What do you all think? Which is better and why?
Can you really use names as primary keys? Isn’t there a high risk of several people with the same name?
If you really are so lucky that your name attribute can be used as primary key, then – by all means – use that. Often, though, you will have to make something up, like a customer_id, etc.
And finally: ‘NAME’ is a reserved word in at least one DBMS, so consider using something else, e.g. fullname.