0

In the context of user account management, I'm using Firebase. So for each login, the front-end sends an Auth ID, a FCM token (for sending notifications to the user), and the usual user details. Each item goes on its own column. With a couple of uniqueness constraints it is all nice. Sometimes, the FCM token is different, so I need to check for that and update/insert accordingly.

Now, I need to extend the system so that the same user can login to the same account on multiple devices. And all the devices should get the notification.

So the auth ID and everything else remain the same but there will be different FCM tokens for each device. I can put all the different tokens in 1) an array, 2) a json object, 3) have a separate table for FCM tokens, 4) have multiple rows in the same table each with a different token.

Option 4 is (probably) obviously terrible.

Option 3 is probably good, but will involve multiple db calls.

Options 1 and 2 seem nice, and I'm inclining towards them but I don't know the full ramifications.

So any help to figure out the right design choice will be appreciated.

I'm using Postgresql 13.

2
  • 1
    Option 3. Have a table of (user_id, device_id, fcm token), and JOIN whatever you need when querying to avoid multiple roundtrips.
    – AdamKG
    Commented Aug 25, 2021 at 17:43
  • What is the argument against arrays/json-objects?
    – ahron
    Commented Aug 25, 2021 at 18:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.