0

I’m trying to build a mobile app that involves users following each other. I’ve seen posts (here) that say it is a cardinal sin to store a users’ followees and followers as a list in a SQL database as each “cell” should only store one discrete value.

However, is this the case for noSQL, document-based databases? What are the pros and cons of storing followers and followees as a list in the user document, vs storing it in a separate collection?

The only ones i can see now is that retrieving the follower/followee data (could be?) faster for the former method as you don’t have to index the entire follower/followee collection, unlike the latter method (or is the time difference negligible?). On the other hand, one would require 2 writes every time someone follows/unfollows another user, which may be disadvantageous for billing in cloud databases, but might not be a problem if the database is hosted locally (?)

I’m very new to working with databases so I’m hoping to get some insight from more experienced people about long term/large scale effects of this choice. Thanks!

Nathan Tew
  • 290
  • 1
  • 2
  • 14
  • The alternate option in a standard database would be to create a followers/following table that has who followed and who they're following. That table would allow you to query a list for both who is following a user, and who that user is following. I'm not sure how straight forward it would be to do both directions using a document based database, personally not much experience with noSQL. – procopypaster Feb 24 '22 at 06:26

0 Answers0