Hi,
I have a question regarding data Sharding on Many-To-Many relationship.
Let’s say we are building a chat app and we have two objects: User and Group, which are Many-To-Many relationship. Now we are going to shard the database and we basically have two options:
- Shard by userId
- Shard by groupId
If I go with either approach, how do I store the other object ?
Eg: I decide to shard the database using groupId. When what should I do with the group object ?
- Duplicate group object in each shard where this shard has user in the group
- Store group object somewhere else (A standalone database maybe) and then store User_Group relations in each shard
I think both methods has some drawbacks but I can’t find more information online regarding this point. Does anyone have ideas how to solve this issue?
Thanks