'What is the difference between MySQL and NoSQL Database?
I have been asked this question in several interviews and I am looking for answers in the terms of how do we choose between MySQL database and NoSQL database for a certain project. what parameters to focus on while doing this? Can anyone please explain with an example?
Solution 1:[1]
MySQL is a product name belonging to a family of technologies called Relational Databases. Other examples are PostgreSQL or Microsoft Access.
When using relational databases your data should be structured and the database schema designed ahead of time, using a technique called data normalisation and defining the relationships between tables. It is table based which means data is split into different tables and if data is needed from several tables it is accessed through referential keys using Standard Query Language (SQL). Relational databases are good for transactional data that need to be ACID compliant. Like banking transaction where a transaction should be completed or rolled back.
NoSql is not a product name it is a description of database type. Nosql databses don't use SQL to retrieve the data. Some NoSql databases which are Mongodb or Couchdb these databases are document based and they offer more flexibility as you don't have to define a schema ahead of time. It is also easier to use NoSql for large amounts of data as you can more easily scale the databases and use an "Eventually Consistent" data model. So for example on social media where a post is liked or commented on. That information will be captured and replicated to all the databases eventually.
Solution 2:[2]
SQL databases are vertically scalable, while NoSQL databases are horizontally scalable. SQL databases are table-based, while NoSQL databases are document, key-value, graph, or wide-column stores. SQL databases are better for multi-row transactions, while NoSQL is better for unstructured data like documents or JSON.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Faysal Ahmed |