Hello,
I'm creating a community of photographers, and I'm still trying to figure out which kind of DB could be better use for this kind of things.
So my question is: when is it better to use MySQL and when MongoDB (or NoSQL in general). For example, I've read that Hashnode uses MongoDB. So, why did they choose it instead of a MySQL?
Thank you in advance and sorry for my english.
P.s. I'm planning to code this website in ReactJS and NodeJS.
Some interesting articles you might want to read
Sandeep Panda
co-founder, Hashnode
MongoDB is a general purpose document database built with high availability and scalability in mind. MySQL, on the other hand, is a relational database which stores data across multiple tables and uses joins to build associations.
When to use MongoDB
MongoDB is general purpose and can be used to build wide range of apps. Some of the popular use cases are Content Management Systems, Catalog management, Personalization engines, data analytics platforms etc.
MongoDB is schema-less and that's why it's often easier to get started with. You store data in various documents without worrying about a fixed schema. In MySQL you have to define a schema for your tables and change it with ALTER command when you need to add a new column or other details. For example, ALTER command in Craigslist's MySQL Database would take months to execute. So, they decided to migrate to MongoDB so that they could accommodate data model changes easily without adhering to rigid schema imposed by MySQL.
A community of photographers can definitely be built using MongoDB. If you are going to use Node.js, you should know that they play very well together. In fact most of the tutorials out there use Node.js + MongoDB for building example apps. So, the answer is yes, a community of photographers can definitely be built with MongoDB.
A couple of questions worth asking yourself - what is your expertise level in managing MongoDB deployments? Are you comfortable dealing with NoSQL? Can you build replica sets, manage shards and take backups effectively? Can you choose the right storage engine for your app? However, the good news is that in most cases you can just start small and explore all these advanced options as you go further. But it's worth noting that you have to do all these things as you scale.
One should also remember that MongoDB is not a drop-in replacement for MySQL.
When to use MySQL
As MySQL is a relational DB, it's the best fit for apps that heavily rely on multi-row transactions. For instance, think of the classic example of a banking app where amount X is debited from account A and is credited to account B. You need transactions here and MongoDB won't offer that. So, MySQL is a perfect fit here.
But this doesn't mean MySQL can't be used to build other types of apps. It's still a great choice for wide varieties of apps out there. Many social networks use MySQL and you will be just fine with MySQL for your use case.
In the end it again boils down to the same old principle. Choose what you are comfortable with in order to build and ship the product faster. I chose MongoDB because I was very comfortable with it when we started writing code for Hashnode. A community for photographers can be built with both Mongo and MySQL. It's now up to you to decide which models suits you better.