I have a MySQL table containing names, email addresses etc. for users (table 1
). I also want another table (table 2
) in which data generated by the user, but intended to be anonymous (such as workplace reviews), are stored.
In the event of someone gaining access to my database, I do not want them to be able to easily link the individuals in table 1
to their data in table 2
. Obviously, I need to be able to communicate between the tables to associate the user with his/her data (for example, if they wanted to edit or delete a review).
I understand that it would be impossible to completely failsafe this, but what would best practice be?
Would encrypting the userids in table 2
be worthwhile? Obviously, the encryption key would be stored somewhere on the server, but it would at least provide an additional hurdle.
I thought about hashing the userid in table 2
, so that it could be queried from table 1
, but without it being possible to query table 1
from table 2
. Is this is sensible? I can't be certain that there wouldn't be a situation in the future where I could want to query table 1
from table 2
, and this would preclude me from ever doing so.