Reputation: 4027
I am having a gender
table as: gender_id | gender_label
Will it be a bad practice if I remove the gender_id
column, as gender_label
is also unique and can be used as a primary key?
I know surrogate keys should be used wherever possible as they are efficient and fast to search.
But will it make any difference for above scenario? How?
Upvotes: 1
Views: 777
Reputation: 142296
I have written hundreds of tables. 2/3 of them have a "natural" key; 1/3 have a "surrogate key".
From that, I deduce that the answer to your question is "it depends".
OK, so what does it depend on?
UNIQUE
? If so, probably you should use it.country_code
taken from an international standard is, in my opinion, better than a 4-byte INT
.In your simple case, is gender_id
strings like M/F/etc? That's what I would use. Actually, I might not have the table at all; instead have gender
in other tables as ENUM('unknown', 'male', 'female', 'other')
Upvotes: 1