SQL vs NOSQL

Sr No
SQL
NOSQL
1
SQL databases provide store of related data tables
NOSQL databases store JSON-like filed value pair documents
2
SQL tables create a strict data template, so it’s difficult to make mistakes
NoSQL is more flexible. It can store any data anywhere which leads to consistency issues.
3
SQL has schema information such as primary keys, indexes and relationships.
In NoSQL data can be added anywhere anytime. There is no need to specify document design. NOSQL generally adds id value automatically to each document.
4
When data requirement is clear SQL is more suitable
When data requirement is not clear NOSQL is more suitable
         
5
SQL enforces data integrity rules using foreign key constraints
Ideally one documents has all the information.
6
SQL transactions ensure that either all operations are successful or failed.
Updating document is atomic. But there are no transaction equivalent of updating multiple documents
7
SQL is lightweight declarative language

For example :

INSERT INTO book (
  `ISBN`, `title`, `author`
)
VALUES (
  '9780992461256',
  'Full Stack JavaScript',
  'Colin Ihrig & Adam Bretz'
);
UPDATE book
SET price = 19.99
WHERE ISBN = '9780992461256'


NOSQL queries are JSON-like.

For example :

db.book.insert({
  ISBN: "9780992461256",
  title: "Full Stack JavaScript",
  author: "Colin Ihrig & Adam Bretz"
});










db.book.update(
  { ISBN: '9780992461256' },
  { $set: { price: 19.99 } }
);

9
A well-designed SQL database will almost certainly perform better than a badly designed NoSQL equivalent and vice versa.

Generally NOSQL is faster than SQL
10
To distribute load on multiple servers is tricky in SQL
Very easy to scale
11
SQL faces less issues as compared to NOSQL
System admins has less experience to NOSQL databases which lead to security or system problems.
12
Where to use SQL:

  1. Data requirement is known
  2. Data integrity is essential
Where to use NOSQL:

1. Evolving data requirement
  2. Speed and scalability is imperative




1 comment: