Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Would you consider this a natural primary key?

I'm writting a program with users who are identified by an id called RFC. In Mexico, this RFC is a 13 characters string used to identify tax payers in our country. No one, in the whole country, has the same RFC so I thought this would be a perfect natural primary key. This RFC would serve as a foreign key in other tables.

The thing is, I'm concerned about system performance. Do you think it would be better to use an auto incremented integer value associated to every RFC?

Cheers!

like image 216
expora Avatar asked Dec 10 '22 14:12

expora


2 Answers

Before you worry about perfomrance, think about privacy. Is RFC in Mexico like social security # in the USA? If so, you definately don't want to build a system that depends on it since you may be forced to treat it differently/encrypt it etc.

I would suggest an auto-incrmenting integer key and store RFC as needed for your privacy needs.

like image 181
n8wrl Avatar answered Dec 25 '22 10:12

n8wrl


My thought is that anything subject to political whims, including "wow, there'll never be more than one person using this number" is a red flag for creating your own primary key (auto increment int).

like image 23
Marc B Avatar answered Dec 25 '22 10:12

Marc B