I would choose a relational database for the nosql database for this approach.
The first thing you need is the basic structure of the icon.
ID (int) Title (Varchar 255) Image (Varchar 255) - would hold location to image Points (int)
Then you will need to save all the badges that the user earned. Therefore, in the "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 that you cannot request all the icons for each action performed, so you should also keep a record for each action. So say in the "posts" table, for example:
Possible_badges (Varchar 255) - serialized array of Badge ID's
Then you can normalize and provide only your icons associated with a specific task in your rules engine.
It’s best to start playing with them if you don’t understand what it is, what you have to compromise and go for the basic logic, so only award badges for tasks that can be measured by database records (mostly numerical data). Or spend more time training (and pulling hair).
George Reith
source share