SQL | NoSQL |
---|---|
Relational Databases | Non-relational/Distributed Database |
Table based, based on # of rows of data | Document Based, based on key-value pairs, documents, graph databases or wide-column stores |
SQL db's have predefined schema, scaled by increasing horse power of hardware (Scales Vertically adding CPU, RAM, SSD, etc on single server) | NoSQL db's are horizontally scalable, scaled by increasing the db's servers in the pool of resources to reduce the load (Scales Horizontally, adding more servers) |
Db Examples: MySQL, Oracle, Sqlite, Postgres, MS-SQL. Uses SQL (Structured Query Language) to manipulate data. | DB Examples: MongoDB, BigTable, Redis, RavenDBb, Cassandra, HBase, Neo4j, CouchDB. Uses UnQL (Unstructured Query Language), varying syntax depending on db used. |
Good for complex query intensive environments not best fit for hierarchical data storage. | Not good for complex queries. Fits better for hierarchical data storage and large data sets. |
SQL databases are great for storing and processing structured data.
An example of structured data is a defined table that includes fields like date, name, address and credit card number.
The kind of data that fits good for a NoSQL db is unstructured data.
Examples of unstructured data are social media posts, texts, mobile activity, internet sensor data.
NoSQL databases are best for hierarchical data storage.
NoSQL would be best for scalability since it is as easy as adding a few more servers.
Structured Query Language
Relational databases are based on the relational model, an intuitive, straightforward way of representing data in tables.
It works with data structured as a table with columns and rows.
A predefined table that includes fields (columns) and Records(rows) of data. All records in that table have to follow this schema.
MongoDB is a NoSQL Database.
In the database, instead of tables in SQL, we have ‘collections.’ In a collection we have documents that kind of look like JSON or JS objects with no schema.
In the MongoDB data base, we have collections which are like the tables in a SQL database, and we have documents which are like the columns and rows.
It depends on the type of data that you’re storing and the type of application you’re building. But NoSQL is more flexible because it is schema-less, no or few relations for reading data, performance for READS and WRITES is great and NoSQL can scale horizontally and vertically.
Having none or few relations can cause updating data to be tedious, the schema-less data structure can be a disadvantage when creating data.
References
SQL vs NoSQL Database Differences Explained with few Example DB