In this article let us see about basic differences between SQL and NoSQL and try to understand the structure of both database models.
SQL | NoSQL | |
Data Model | Relational model.Structured database. Stores data in tables | Non-Relational model. Semi-Structured database. Stores data in JSON documents, graphs, key value pairs, column based. |
Query Language | Structured Query Language | No declarative query language. |
Schema | Predefined or Static | Dynamic |
Popular Database Systems | MySQL, PostgreSQL, Oracle, MS-SQL | MongoDB, Apache HBase, Cassandra, Amazerticalon DynamoDB |
Scaling | Vertical | Horizontal |
Transaction | ACID (Atomicity, Consistency, Isolation, Durability) | BASE (Basically Available, Soft state, Eventual Consistency) |
Flexibility | Not very flexible in terms of design | Very flexible in terms of design |
Example | SELECT id, name, address FROM students WHERE age>12 LIMIT 5 | db.students.find( {age:{$gt:18}}, {name:{1,address:1} ).limit(5) |
Relational
In the above images we can understand the models of SQL and NoSQL databases.
If your application has fixed structure and does not require frequent modifications then SQL is best. But if your application is rapidly changing and growing like in big data analytics then NoSQL is best.