Reputation: 806
I have thought about two types of user notification systems .
Both of them has a subscriptions table, where users subscribe to a particular channel.
Below schema is for the table that stores events.
When something new happens:
|id| |type| |uid| |read| |created|
1 2 2 0 1234
This system , inserts a new row for every user subscribed to a channel when something new happens in that channel.
Drawbacks:
Advantages:
When something new happens:
|id| |type| |created|
1 2 1234
In this system, it inserts only one row for one event i.e it is not specific to a user . The user then reads the table and checks if that event happened is in his subscribed channel and then also compares if the created time is greater than last read time .
Drawbacks:
Advantages:
Which do you think is better for following conditions:
Upvotes: 1
Views: 145
Reputation: 163488
I suggest using a combination of your approaches.
Have a table with your messages, and then another table associating the per-user status of those messages with the user. For instance, your messages table might be as simple as:
Your other table might have:
Then, if you have any other specific information for that user, you can keep track of it outside of the original message. If you update that original message, it is still updated for all users.
Upvotes: 1