Facebook like notifications tracking (DB Design)

前端 未结 6 979
无人及你
无人及你 2020-11-28 02:40

I am just trying to figure out how Facebook\'s database is structured for tracking notifications.

I won\'t go much into complexity like Facebook is. If we imagine a

6条回答
  •  误落风尘
    2020-11-28 02:43

    I am also trying to figure out how to design a notification system. Regarding notification status (read, unread, deleted, archived, ect) I think that it would be good a good candidate to for ENUM. I think it is possible that there will be more than two different types of status other than READ and UNREAD such as deleted, archived, seen, dismissed, ect.

    That will allow you to expand as your needs evolve.

    Also I think it may make sense (at least in my case) to have a field to store an action url or a link. Some notifications could require or prompt the user to follow a link.

    It also may make sense to have a notification type as well if you want different types. I am thinking there could be system notifications (such as a verify email notification) and user prompted notifications (such as a friend request).

    Here is the structure I think would be a minimum to have a decent notification system.

    users
    -------------
    id
    username
    password
    email
    
    notifications
    -------------
    id
    user_id (fk)
    notification_type (enum)
    notification_status (enum)
    notification_action (link)
    notification_text
    date_created (timestamp)
    

提交回复
热议问题