sql - Username or Userid -


i've seen many discussion whether better use userid or username primary key table. userid allow flexibility of later changing username if desired. way implement security. however, username unique identifier.

if choose userid primary key, best way enforce username take on unique value?

if choose username, problems should aware?

i declare userid primary key there other tables referencing user record through userid , thereby useful enforce foreign key constraints.

if username needs unique, declare non null column , define unique key constraint. non null property prevent single null value allowed unique key constraint in column. so, set on username similar of primary key.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -