I am designing a social app using java android with FireStore as backend. In the beginning, Firestore modeling can be a big change, as I have read I am trying to keep Documents small and not to make too many subcollections, let´s suppose the following scenario:
A User can create a few profiles
A profile has interests
A user can follow or unfollow many profiles so a profile can be followed by a lot of users
Users (Collection)
uid: uidUserOne
name: jeff
Profile (Collection)
idProfile: idProfileOne
name: nameProfileOne
interests: { yoga: true, running: true, climbing: true }
createdBy: uidUserOne
Here start my doubts not sure how to model de Follow/unfollow functionality, I have three options in mind:
Option A
Make a collection in which each document maps a single user follows one profile relationshipfollowers (Collection)
uid: uidUserOne
idProfile: idProfileOne
Option B
One document maps the followers of each profile, I save the user UIDs that follow the profile in an array.
followers (Collection)
idProfile: idProfileOne
followers: { uidUserOne: true, uidUserTwo: true, ...}
Option C
One document maps the follows of each user, I save the profiles ids that are followed by the user in an array
followers (Collection)
uid: uidUserOne
follows: { idProfileOne: true, idProfileTwo: true, ...}
I would like to know which options are the best, A B r C also if it can be a better one... probably
And I have another doubt, how can I do the following query:
Let's say I am user One and I already follow two profiles with yoga interest so I want to list, profiles with yoga interest which I do not follow yet, not sure how to accomplish this.