Achievements / Badges system

后端 未结 4 776
情歌与酒
情歌与酒 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:21

    I think this is one of those cases where your many-to-many table (Badges_User) is appropriate.
    But with a small alteration so that unassigned badges isn't stored.

    I assume assigned_at is a date and/or time.
    Default is that the user does not have the badges.

    Badges     |    Badges_User      |  User
    ----------------------------------------------
    bd_id      |    bd_id            |  user_id
    bd_name    |    user_id          |  etc
    bd_desc    |    assigned_at      |  
               |                     |
    

    This way only badges actually awarded is stored.
    A Badges_User row is only created when a user gets a badge.

    Regards
        Sigersted

提交回复
热议问题