How should I make a follow system sql or nosql?

Viewed 246

I'd like to programm a system where a user can follow another user but I don't know if I should do it with a nosql db like mongodb or any other or is it better with a sql (postgres)?

I know that with postgres I need a pivot table because it is a many to many relationship. I thought I can put in the users collecion something like { followers : [ user_id1, user_id2, user_id3 ], } and I can get them a little faster. In that case I can get the other users by their id. Can I get the followers and the following people of this user like this. is it faster or Am I wrong?

I am planning that every user can have many followers. Also I need that this app can receive many request and for that reason the performace is important.

What should I use in this case? A pivot table with postgres or mongo? By The Way I am using Nodejs.

Thanks in advance!

1 Answers

I would use a NoSQL database. As you are saying performance and scalability are very important and that are things NoSQL databases like MongoDB perform greatly at. They are also very scalable, so you won't have to deal with relational SQL issues there.

If you want you can read more here: https://www.sitepoint.com/sql-vs-nosql-differences/

Related