About the schema design for below scenario

Here is my question on this scenario.

Schema

DocAlert

Id

title

User

Id

userName

email

Records

DoclAlert

1 docalert1

2 docalert2

3 docalert3

4 docalert4

User

1 abc abc@abc.com

2 abc abc@abc.com

3 abc abc@abc.com

4 abc abc@abc.com

Here each docalerts can be associated to multiple users. Means

User with Id 1 contains DocAlert 2,3

User with Id 2 contains DocAlert 1,2

User with Id 3 contains DocAlert 2,3 & 4

Here are the approaches

  1. Sync DoclAlert table completely and maintain the array of DocAlert Id’s in User collection. Here DocAlerts which are not associated to the user is also synced to device.

  2. Embed DocAlerts in User Collection and this leads to data duplications

Questions

  1. Considering these drawbacks, After logged in to the application I want to sync only specific set of docalert records to the device from DoclAlert collection… How do I achieve this?

  2. Is there any way to skip one attribute from syncing to local Realm DB.

  3. I have given only read access to records with partition key “XXX” in collection “YYY”. After syncing, When I try to update records from mobile application it is allowing me to update record in my local RealmDB and ends the session and connection as well with error “ ending session with error: user does not have write access to partition (ProtocolErrorCode=206)”. This should not end connection/session here right?