R
R
Renhor2019-06-15 20:07:09
MySQL
Renhor, 2019-06-15 20:07:09

Which database, MySQL or MongoDB, should I use for my node site?

Good afternoon! Before that, I used PHP + Mysql on the backend, now I am writing a project with a backend on Node.
The data in the new project will be approximately the same as in the old one, namely:
1) Users
2) Players
3) Orders
4) Reviews
5) Chat
6) Notifications
7) Matches
8) Heroes
9) Items 10
) Blog
add. tables with a one-to-one relationship.
Many-to-many or one-to-many relationships are often used in the database (for example, by user id you can get his orders, reviews, chat messages, etc., from the order you can find the user, review, chat, matches.).
For me, the "elasticity" of mongodb looks attractive, for example, I could refuse some tables (collections) and dependencies one to one, simply by creating an additional object field in the record (document).
But on the Internet, I came across a phrase on a toaster that if there is a 10% chance that there will be relationships / connections between tables, then it is better to use relational databases (in my case, mysql).
If this is true, then what difficulties would I face if I decided to use MongoDB after all?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
Frozen Coder, 2019-06-15
@Renhor

You have to look at the data and how it will be used. If they are full of relationships, i.e. are clearly relational in nature, you need queries with join and transactionality, then take MySQL and that's it. In addition, MySQL has the ability to store JSON and even build indexes on it.
Mongodb is good to take when the data can be expressed through a document. Those. embed all related entities into one document to the maximum. Join in fact must be done by hand, i.e. through the app. Many features of relational databases seem to be there, but they work worse than in relational ones (there is a schema, and transactions, and like join, but it’s like that, it’s better to avoid it if possible).

P
Pasechnik Kuzmich, 2019-06-15
@Hivemaster

Get ready for more memory consumption than with MySQL.

I
Ivan Shumov, 2019-06-15
@inoise

Each solution has its own database. We need to look at the project as a whole and how everything will communicate. Will the architecture be microservice or monolithic? Will there be SPA or SSR?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question