Audit columns – Created by and Updated By

 Audit columns - Created by and Updated By

Audit columns – Created by and Updated By

I have seen two database designs to store the value in Created by and Updated By columns as:

  1. Store the PK of user in Created by and Updated By columns
  2. Store the user name in Created by and Updated By columns

Now you may have question: What is best practice to store the value in the Created by and Updated By columns and why?

My opinion is PK of user (user id) is preferred over user name. There are various reasons, some of them are mentioned below:

  1. User id is integer and User name is char/varchar. Integer occupies less space and works faster in terms of indexing.
  2. User id never gets changed, whereas user name can be changed over a period of time.
  3. With user id, you can retrieve other information for user master, but will be expensive to do it through user name.
  4. Data validation can be done through FK for user id and not for user name.

You may share your opinion or comment.