So I am in the process of updating an existing notifications database design AS it wouldn't be optimal for storing group chat notifications.
Notifications:
- id
- user_id
- type (enum)
- thread_id (used for chat notifs)
- contact_request_id (used for linking contact requests to a notif)
- created_at
- read (whether they read it or not)
At the moment, for each contact request, we would need to store 2
rows, for every single message, we would need to UPDATE 2
existing rows (each user has there own notif)...this is the main reason I want to find an optimal solution! Because when we add group chats, storing and updating 2..* rows will get ugly, and I can see data getting out of sync quickly.
I have thought of 3 solutions:
- We create 1 notification AND link the users to that notification in another table (
notification_users
) - We create a seperate table for message notifications. So that we can facilitate for multiple users per notif?!