Hi,
When we are sharding the database to store the 3 tables (i.e., Users, Photo_data and User_follows), how is it done for other tables if we consider sharding based on photo id.
There are 2 different cases -
-
All users data is stored in all shards.
If there are 10 different shards, all 10 shards have complete users data and user_follows data
Cons:
a. Consistency takes a hit
b. Massive duplication of data (esp. user follows data which could be massive) -
Users data is stored in 1 shard
Cons:
a. If a new photo of a user is added in different shard (i.e., photo is in shard 1 and user data is in shard 2), then when data needs to be fetched, query must be done across all shards.
Seeing the above problems, I can’t consider a better approach than sharding based on user id. Please correct me if I missed something or misunderstood something.