A
A
Artem00712018-02-18 13:47:38
Database
Artem0071, 2018-02-18 13:47:38

How to make the "Notifications" table in the DB correctly?

There are users and they should receive notifications for various actions.
Notifications can come in several ways (from the system itself, by mail, via VK, via Telegram). The user can set up notifications so that the notification will come to VK and email, but will not come via other networks. It may also be that the notification can only be delivered in the system and by mail, but not in social networks.
In general, it's kind of confusing.
At the moment, I came to the conclusion that there are 2 tables
notifications('id', 'type', 'viaPusher', 'viaEmail', 'viaVk', 'viaTelegram');
Here I create the notification types themselves
. For example
('newOrder', 1,1,1,1); // i.e. for "new order"
there is also user_notifications('user_id', 'notification_id')
It turns out that if there is a record, then a person can receive a notification
But the problem here is that a person cannot set up what he would like to receive a notification for, but subscribes, as it were, to everything immediately what is available
In general, I am confused with this system. I have already redrawn 200 tables. But some problem always pops up. Either the user cannot configure something, or the system cannot set the initial data
. And I don’t want to make one table “user notifications” because it can be huge in the future, but I want to do it correctly and beautifully from the very beginning

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Tsvetkov, 2018-02-18
@yellow79

The user_notifications table is not needed, the notifications table should be changed to something like this:
notifications('id', 'user_id', 'type', 'viaPusher', 'viaEmail', 'viaVk', 'viaTelegram'); // added user_id
For each event type, create a separate entry for each user

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question