DEV Community

Discussion on: Database 101: How social media “likes” are stored in a database

Collapse
 
tracker1 profile image
Michael J. Ryan

This is discussed in TFA. You wind up creating a new record for each update to a counts field in a posts table.

Having the separate analytics table, you can have atomic counters that effectively do the same. Yes it's an n+1 request,. But with horizontal scaling and often faster than joins for a single view item.

Collapse
 
jdgamble555 profile image
Jonathan Gamble

I think you're misunderstanding. You wouldn't use joins in my case. It would save the value, it would just recalculate it instead of incrementing. After dealing with Firestore, I don't trust increments to be accurate.