Realm design best practice - will ROS work for this use case?

ros

#1

Hello,

Trying to design an app here, and it’s not super clear to me the best way to design it using Realm.
Essentially - the app will have a bunch of accounts, which own items.

The complication arises when I add another feature into the mix – Groups. I’d like accounts to be able to be members/admins of groups - naturally an extension of Realm’s permissions.
For this, I was thinking of having a realm per user, and also per group. On top of this, I thought it would be best to have a global realm containing minimal information about user/group and links to each of their realms.
However, I’d also like Groups to have items themselves - specifically the items that users that are part of that group have added to the group. Not sure how to handle this relationship because items are fundamentally owned by the user - and thus located in the user’s realm. But, I must also be able to query for all items in a group - this seems inefficient if I store links to a user’s realm and have to fetch the item every time.

Is there a workaround for this type of relationship -? or a better way to design my realms in general?


#2

Sounds like your use case is better suited for Partial Synchronization - effectively this allows you to store your entire dataset in a single Realm and have users subscribe (download) portions of that. This API comes with its own fine-grained permission system that would allow you to set access levels at the object level.


#3

I could see how that works - but doesn’t this imply that everything in this app will be stored in a single realm? For some reason that seems to me to be bad practice - especially as the app scales


#4

Are you concerned about the performance or the file size? The central Realm will indeed become fairly large as the app scales, but that resides on the server (where supposedly you can have terabytes of storage) and every device downloads just portions of the data it’s interested in. For example, if a user is a member of 5 groups, they’ll download the data, relevant for these 5 groups and not for the hundreds/thousands other groups. Ultimately, the file size difference on the client should be negligible when you compare 5 different Realms with a single group and a single Realm with 5 groups.


#5

I’m more concerned about the performance on the server side - will one big central realm get bogged down if it grows too large/has to handle too many requests at once? Just not entirely sure how much it can scale/the details