From SQL to Firebase — How to structure the DB for a social network app
Gil Goldstein
1705

Thanks for a great article!

I just wonder where to store the post Likes counter. The post data can be scattered all over the place (like in a users timeline etc.) so should you store it in one place (/likesCounter/<post_id>/likes = 0) so you only need to update that one place whenever a user likes/unlikes an post and have one extra read query each time a post shows,

or should you update a likes counter inside the postData for every single place the post exists whenever a user likes a post? (which would be lots of writes in case someone has a lot of followers where lots of likes/dislikes could trigger millions of fanout writes)

I guess the same answer will apply to a posts comments counter as well :)

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.