Sql = is a Standard Query Language ,is the core of relational database and is used for accessing and managing database.

→ It helps you to retrieve data from a database whose structure is completely made of tables with rows and columns and these tables are interlinked with each other with specific values which can be retrieved from these tables with the help of queries.

→ allows you to make relationship between tables, can be one to one,one to many,many to one,many to many.

→ based on ACID properties.

A=Atomicity
C=Consistency
I=Isolation
D=Durability

→Example = Oracle, MySql , PostgreSql , Microsoft SqLServer , SqlLite, etc..

NoSql = known as not only SQL database, provides mechanism for storage and retrieval of data and is the nest generation database . It has no specific schema(tables) and can handle huge amount of data .It stores data in the form of collections in document.

— No specific schema

— No Query Language

— No or a few relationships

— Unstructured Data

follows CAP Theorem-

C = Consistency
A=Availability
P=Partition Tolerance

→Example= MongoDB , redis , Apache HBase , cassandra, etc..

→Follows CAP theorem —

Image for post
Image for post

CAP theorem is also called brewer’s theorem. It states that is impossible for a distributed data store to offer more than two out of three guarantees

  1. Consistency = The data should remain consistent even after the execution of an operation. This means once data is written, any future read request should contain that data. For example, after updating the order status, all the clients should be able to see the same data.
  2. Availability =The database should always be available and responsive. It should not have any downtime.
  3. Partition Tolerance =Partition Tolerance means that the system should continue to function even if the communication among the servers is not stable. For example, the servers can be partitioned into multiple groups which may not communicate with each other. Here, if part of the database is unavailable, other parts are always unaffected.

Let’s consider two famous databases one for SQl(MySql) and one for NoSql(MongoDB) — —

Basic queries for Sql and MongoDB queries —

Sql: create table info( id int(11) , name varchar(20) , age int(20), city varchar(20));

MongoDb: db.createCollection(“info”)

Insert query-

Sql: insert into info( id , name , age , city) values(1, “XYZ”,12,”Delhi”);

MongoDB: db.info.insert({ id:1 , name:"XYZ", age :12 , city: "Delhi"})

Read -

Sql: select*from info;

MongoDB: db.info.find()

Update-

Sql: update info set name=”ABC” where id =1;

MongoDB: db.info.update({id:1},{$set: {name:”ABC”}},{multi:true})

Remove-

Sql: delete from info where name=”ABC”;

MongoDB : db.info.remove({name:”ABC”})

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store