database design for 'followers' and 'followings'?

后端 未结 4 1607
醉话见心
醉话见心 2020-12-23 00:01

Dear database experts/programmers:

I have a mysql table with users information, such as

id      user_id         name etc.
1       userA            
2         


        
4条回答
  •  礼貌的吻别
    2020-12-23 00:36

    Here is my design.

    Id    userId(PK)  followerId     followedDate         unfollewedDate
    1     123         456            YYYY-MM-DD HH:MI:SS  YYYY-MM-DD HH:MI:SS
    ...   ...         ...            ...                  ...
    

    I assumed userId - followerId combiation is unique. Dates can be useful. For example I'm thinking about to use if user unfollow and follow again in 5 minutes, it doesn't generate notification. I assume user made it by mistake. And I can analyze following statics by date.

提交回复
热议问题