SQL Vs Nosql DB
SQL Vs Nosql DB
DATABASES
WHAT IS A DATABASE?
A database is a systematic
collection of data which can be in
different formats.
For Example
Banking system.
WHAT IS A
RELATIONAL DATABASE ?
SQL pronounced as “S-Q-L” or as “See-Quel” is primarily
Relational Databases.
For Example
A simple database for a small shop can have two tables,
customer and items.
NON - RELATIONAL OR
DISTRIBUTED DATABASE ?
Non-relational databases store their data in a
non-tabular form.
For Example
Document databases
"firstname" : "Rahul"
"title" : "Programmer" ,
"birthdate": "12-09-1997"
Colon depicts
“hiredate" :”18-06-2010”
assignment of a value
"address” :
”Sector 09, Chandigarh”,
to a name
“Region” : “Punjab”,
“postalcode”: “500025”,
“Country”: “India”
},
For Example
Friends
Likes
Person
Lives in
Likes
State Hotel
Location
Key Value Data-Model
corresponding value.
Name Rahul
ID 101
State MP
Country India
Column Oriented Databases
DATA SET
User id 510123 510124 510125
First Name Rohit Karan Abhay
Last name Ranjan Singh Kumar
Salary 45,000rs 40,000rs 25,000rs
SQL TRANSACTIONS
Relational databases follow ACID properties.
Atomicity:
For Example
During a transaction of
transfer of funds, if money is
deducted from one account
but not deposited into
another, due to failure of
transaction in between, the
entire transaction is not
executed.
Consistency:
For Example
Isolation:
Every transaction should
be executed in isolation
from other transactions. If
transactions make
changes to the database
concurrently, it may lead to
errors and overwritten
data.
For Example
If there are two transactions, one for transfer of funds
and other for printing total data, if printing takes place
before complete transfer, it will show inconsistent. This
is avoided by serializability and locking protocols.
Durability:
CAP THEOREM ?
The CAP theorem (Brewer’s theorem) states that a
distributed system or database can provide only two
out of the following three properties:
Consistency:
Similar to ACID Properties, Consistency means
that the state of the system before and after
transactions should remain consistent.
Availability
This states that resources should always be
available, there should be a non-error response.
Partition tolerance:
Partition tolerance: Even when the network
communication fails between the nodes in a
cluster, the system should work well.
Consistency
CP category
CA category
There is a risk of
some data
Network Problem might
Pick two
Partition
Tolerance Availability
AP category
base properties:
BASE stands for Basically Available, Soft state,
Eventual consistency.
Basically Available:
Soft State:
Data values in the
database may change
over time. This is due to
the fact that there is no
immediate consistency,
and the BASE model
delegates the
responsibility of
consistency to developers.
Eventually Consistent:
Querying Languages
SQL Databases :
Some relational database products support pure SQL.
NO-SQL Databases :
NoSQL databases use dynamic schemas.There
are no predefined data structures for organising
data.
SCALABILITY IN
DATABASES
Scalability in SQL Databases :
SQL databases mainly scale vertically.
For Example
When to use
SQL VS NO-SQL ?
When to use SQL:
BOSSCODER
professionals
Bosscoder alumni