SQL vs NoSQL

Clash of the Titans ,which one is fbetter and faster ? Is NoSQL faster than SQL? Not really, as well as the SQL is not faster than NoSQL. Which one to choose than? Both have advantages and disadvantages, lets dig deeper and findout.

Differences between SQL and NoSQL The five critical differences between SQL vs NoSQL are:

SQL databases are relational, NoSQL databases are non-relational. SQL databases use structured query language and have a predefined schema. NoSQL databases have dynamic schemas for unstructured data.

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.

SQL

Structured Query Language (SQL) is a standardized programming language that is used to manage relational databases and perform various operations on the data in them

What are transactions?

A transaction is a logical unit of work that contains one or more SQL statements. A transaction is an atomic unit. The effects of all the SQL statements in a transaction can be either all committed (applied to the database) or all rolled back (undone from the database).

NoSQL

Everybody heard at least once that NoSQL databases are non-relational and that does not have any relation between the data, well that is not 100% true. They are able to have relation between the data but in a different way.

NOTE that this list is not exactly ordered by popularity, there are different metrics for measuring the popularity of a particular database. We will just list the most featured ones.

  • MongoDB
  • Cassandra
  • ElasticSearch
  • Amazon DynamoDB
  • CouchDB
  • Redis
  • HBase
  • RavenDB

Types of NoSQL Databases:

  1. Key-value Pair Based
  2. Column-oriented Graph
  3. Graphs based
  4. Document-oriented

MongoDB in nutshell

As my personal favorite and first go to database for some quick and lightweight projects it has to be MongoDB. Mongo is really easy to use,begginer friendly as support and community is really strong. Lets dive a little bit deeper in what is Mongo and for what it is used.

Advantages of MongoDB Performance Levels High Speed and Higher Availability Simplicity Easy Environment and a Quick Set-up Flexibility Sharding Scalability Ad-hoc Query Support Documentation Technical Support Disadvantages of MongoDB Transactions Joins Indexing Limited Data Size and Nesting Duplicates High Memory Usage What is index in MongoDb? An index in MongoDB is a special data structure that holds the data of few fields of documents on which the index is created. Indexes improve the speed of search operations in database because instead of searching the whole document, the search is performed on the indexes that holds only few fields.

What is ORM?

An Object-Relational Mapper provides an object-oriented layer between relational databases and object-oriented programming languages without having to write SQL queries. It standardizes interfaces reducing boilerplate and speeding development time. In simple words you dont need to be expert in SQL and you dont need to know to write queries in order to use it, you just need to use ORM with a help of libary.

In my opinion best ORM libaries for JavaScript and TypeScript are : For SQL Objection.js, Sequelize and Knexjs SQL Query Builder , whereas for MongoDB Mongoosejs is without competition.