Achievements / Badges system

后端 未结 4 810
情歌与酒
情歌与酒 2021-01-29 19:29

I have been browsing this site for the answer but I\'m still a little unsure how to plan a similar system in its database structure and implementation.

In PHP and MySQL

4条回答
  •  耶瑟儿~
    2021-01-29 20:26

    I would keep a similar type structure to what you have

    Badges(badge_id, badge_name, badge_desc)
    Users(user_id, etc)
    UserBadges(badge_id, user_id, date_awarded)
    

    And then add tracking table(s) depending on what you want to track and @ what detail level... then you can update the table accordingly and set triggers on it to "award" the badges

    User_Activity(user_id, posts, upvotes, downvotes, etc...)
    

    You can also track stats from the other direction too and trigger badge awards

    Posts(post_id, user_id, upvotes, downvotes, etc...)
    


    Some other good points are made here

提交回复
热议问题