Note that there are some explanatory texts on larger screens.

plurals
  1. POLooking for a good database structure to achieve Facebook/SO like notifications
    primarykey
    data
    text
    <p>I want to be able to have notifications on my site, similar to the way SO does it. I have looked for a good table structure to do this, but I cant seem to figure it out.</p> <p>I was thinking something like this.</p> <p>Notifications</p> <p><code>id</code>, <code>notification_type_id</code>, <code>user_id</code>, <code>type_id</code></p> <p>Notification Types</p> <p><code>id</code>, <code>notification_text</code></p> <p>Where the notification type would relate to either a new post, a new comment, or whatever features I add later down the line... User Id would relate to whoever the notification is for. Type_id and notification type would go hand in hand, so if the notification_type was a new comment, the type_id would be the comment_id to go to.</p> <p>This seems good to me, but i want to be able to notify ALL users when something changes.. like on facebook when you comment on something, you get a notification that someone else has also commented on the same thing after you.</p> <p>I cant seem to figure this out... Help wanted</p> <p>Thanks</p> <p><b>EDIT: </b> The way I thought about it was, the notification_type_id would map to the notification_type table, which would hold the text for each notification ("You have a new comment", "blah blah blah has also commented on blah blah blah", etc.), type_id would map to the primary_id of whatever the comment is about. for example, if the notification is saying you have a new comment on your post, then the type_id would be the primary id of the post for easy linking.. IDK, it was just a thought.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload