MYSQL: User - profile details table setup - best practice

后端 未结 3 1005
南方客
南方客 2021-01-30 03:27

Next to your normal user table \"user\"(user_id/user_email/user_pwd/etc), what is the best way to go to store profile information?

Would one just add fields to the user

3条回答
  •  独厮守ぢ
    2021-01-30 04:20

    Table with property definitions isn't the good idea. I suggest to use three tables to store data:

    user(id,login,email,pwd, is_banned, expired, ...) 
    -- rarely changed, keep small, extremaly fast search, easy to cache, admin data
    profile(id, user_id, firstname,lastname, hobby,description, motto)
    --data often changed by user,...    
    user_stats(id,user_id,last_login,first_login,post_counter, visit_counter, comment_counter)
    --counters are very often updated, dml invalidate cache
    

    The better way to store authorisation and authentication data is LDAP.

提交回复
热议问题