Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using MySQL and Mongodb together

Tags:

I have worked with MySQL more than MongoDB, but from what I've learned from MongoDB it's just what I needed, but it also has it's limitations that MySQL can do (for instance auto increment)

Would it be smart to use MongoDB for everything, and use MySQL for only certain things?

For instance use MongoDB to store users and everything else, but use MySQL to make for example a ticket system.

like image 342
WittyPleb Avatar asked May 20 '12 19:05

WittyPleb


People also ask

Can I use MySQL and MongoDB together?

It's common to use MySQL as the primary storage and MongoDB as caching/intermediate storage for speed. You can for example have read-intensive data in MongoDB. The data for generating reports is perfect for a relational system like MySQL.

Can I use both NoSQL and SQL?

Using a NoSQL database doesn't mean you can't use SQL; SQL is just the query language. In fact, NoSQL and SQL can be complementary. Some NoSQL databases use SQL to search the data.

Can we use MySQL and MongoDB together in node JS?

Yes it's 100% possible, they use completely different ports and do not care about each other. The server isn't a 'nodejs' server, it's a server that's running nodejs, and you can install anything you want on the server.

When should I use MongoDB and MySQL?

MySQL is a good choice if you are working with a legacy application that requires multi-row transactions and has structured data with a clear schema. MongoDB is a good choice if: You want high data availability along with automatic and instant data recovery.


2 Answers

It sounds perfectly reasonable to use two database technologies in one project. Just make sure you use the right tool for the job.

It's common to use MySQL as the primary storage and MongoDB as caching/intermediate storage for speed.

You can for example have read-intensive data in MongoDB. The data for generating reports is perfect for a relational system like MySQL.

like image 111
ilanco Avatar answered Sep 24 '22 01:09

ilanco


There is a pretty good discussion of Use Cases for MongoDB on the main MongoDB site. In general, if your business case includes the need for transactions and heavy T-SQL functionality, then you'd be better served by using a RDBMS such as MySQL.

Good Use Cases for MongoDB are as follows:

  1. Your data is in a document format, i.e. irregular structure in single documents (that is data doesn't need to be joined)
  2. You are considering using a flat file system (again due to the structure of your data), but you would like 'more' in terms of ability to index/query that data.
  3. Your project is in a state where you genuinely don't know what the schema or structure of your data will ultimately be.
  4. You have specialized data types, such as geo-spatial data, and you want to be able to query against it.
  5. You may have a need to quickly and cheaply scale your data storage location.
like image 24
Lynn Langit Avatar answered Sep 27 '22 01:09

Lynn Langit