I was using Firebase realtime database for my test social network app in which you can just follow and receive post of people you follow. A traditional social network. I structured my database something like this-
Users --USER_ID_1 ----name ----email --USER_ID_2 ----name ----email Posts --POST_ID_1 ----image ----userid ----date --POST_ID_2 ----image ----userid ----date Timeline --User_ID_1 ----POST_ID_2 ------date ----POST_ID_1 ------date
I also have another node "Content" which just contained id of the all the user post. So, if "A" followed "B" than all the post id of B where added to A's Timeline. And if B posted something than it was also added to all of its follower's timeline.
Now this was my solution for realtime database but it clearly have some scalability issues
- if someone have 10,000 followers than a new post was added to all of the 10,000 follower's Timeline.
- If someone have large amount of posts than every new follower received all of those posts in his Timeline.
These were some of the problems.
Now, I am thinking to shift this whole thing on firestore as its been claimed "Scalable". So how should I structure my database so that problems I faced in realtime database can be eliminated in firestore.