JS node - Mongodb x Mysql

Asked

Viewed 3,089 times

5

Why every JS Node tutorial we see, is always shown example in Mongodb.

What you both have that are so used?

Why not use Mysql with Node?

2 answers

7


A reason why the use of Node.js with Mongodb is because they both handle the same data structure natively.

Node.js is a server-side javascript execution environment. Javascript works great with JSON (Javascript Object Notation) and Mongodb is document-oriented, which are similar to JSON objects.

A record in Mongodb is a document, which is a data structure composed of field and value pairs. Mongodb documents are similar to JSON objects. Field values may include other documents, document arrays and arrays.

That is, they both speak the same language. Another factor is that Node.js is very scalable and by being asynchronous is being used a lot in real-time applications that combines with the fact that Mongodb be a Nosql, where it is assumed greater scalability with respect to relational databases.

So much is encouraged that there is the MEAN (Mongodb, Express, Angular, Node.js), which provides structure to work with these technologies.

And yes, it is possible and also commonly used Node.js with Mysql, so much so that there is the ORM Sequelize.

Whether to use one or the other depends on the need and requirements of the business.

0

The non-relational databases (Nosql) are excellent for current new projects, as one of the main problems today is related to processing and fast delivery to the user. And Nosql databases allow this.

Speaking specifically of Mongo + Node (Javascript), both seem to have been made for each other. In addition, performing searches or insertions is something very simple. There are even hours that I forget that I am working with database.

Also use Elasticsearch, which also has JSON type structure, but is slightly more complex communication between Node + Elasticsearch.

I also use Node + Mysql, but it was just a script to do some speed tests, and then pass the data to Elasticsearch. For my project, the same Mysql script took 16 seconds and Elasticsearch 0.01 seconds, 160x faster than Mysql!

Whether Mongodb, Elasticsearch, or other Nosql, I strongly advise to study about them.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.