I wanted to do a Facebook-similiar notifiaction system, but I just can't think of the way, how to realize it.
I read here about various opinions like having one table for it, others says to have two.
However I'm trying the most effecient way with only neccesarry data entries.
This is my notfication
table so far:
id, uid, type, read (boolean), date.
So I thought of one example:
Insert a comment, call notification function that inserts my uid (user_id), type (comment, like, etc), read='1', NOW().
I set read to 1, because I don't want to get notified when I'm posting something. Then I thought I'll update notification
by setting read to 0 by all other users, because they haven't read this new post yet.
But now I'm thinking of another post that will be made 5sec later or something. Then all other read
entries are set to 0 again, which is right, but in this scenario I can't think of displaying (SELECT) the right results for each single user.
Because it isn't specified which user missed which new notification(s).
I hope you could follow me and have any suggestions. If I'm doing it the wrong way in general I'd also appreciate advices.