Best approach for designing framework for badge assigning system

梦想的初衷 提交于 2019-12-03 15:10:37

I would definitely choose a relational database over a nosql database for this approach.

The first thing you need is the underlying structure of a badge.

ID (int)
Title (Varchar 255)
Image (Varchar 255) - would hold location to image
Points (int)

You would then need to store all the badges a user has earned. So in your users section:

Badges (Varchar) - holds a serialized array of badge IDs 
Badge_count (int) - So you can get the total without parsing through Badges.
Point_count (int)

Now you say you can't query against all badges for each performed action, so you should also store an entry for each action. So say in your "posts" table for example:

Possible_badges (Varchar 255) - serialized array of Badge ID's

You can then normalize and give only the badges related to any specific task to your rule engine.

Your best bet is just to start playing with them, if you don't understand what is out there than you must compromise and go for basic logic so only award badges for tasks that can be measured by database entries (mostly numerical data). Or spend more time learning (and pulling your hair out).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!