0% found this document useful (0 votes)
9 views17 pages

Lecture 27 (Week 16) -NOSQL Part 2

The document discusses the differences between SQL and NoSQL databases, highlighting that NoSQL is better suited for big data, flexible data models, and unstructured data. It explains the CAP theorem, which states that it's impossible for a distributed system to guarantee consistency, availability, and partition tolerance simultaneously. Additionally, it contrasts the ACID model of SQL with the BASE model of NoSQL, emphasizing their respective strengths and use cases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views17 pages

Lecture 27 (Week 16) -NOSQL Part 2

The document discusses the differences between SQL and NoSQL databases, highlighting that NoSQL is better suited for big data, flexible data models, and unstructured data. It explains the CAP theorem, which states that it's impossible for a distributed system to guarantee consistency, availability, and partition tolerance simultaneously. Additionally, it contrasts the ACID model of SQL with the BASE model of NoSQL, emphasizing their respective strengths and use cases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

“Database Management Systems”

CS-222

“NOSQL – Lecture 2/2 ”


By: Dr. Muhammad Muneer Umar
Lecturer in Computer Science
Institute of Computing
KUST, Pakistan
Topic: NOSQL

CONTENTS
• Previous Lecture

• NOSQL is better for

• CAP Theorem

• SQL vs NOSQL

Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

NOSQL is better for..


Big Data

Flexible data models – No predefined Schema

Handling of unstructured data

Cheaper to be managed

Scaling is easy
3
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

CAP Theorem
• Suppose three properties A
of a distributed system (sharing data) C
• Consistency:
• all copies have same value P
• Availability:
• reads and writes always succeed
• Partition-tolerance:
• system properties (consistency and/or availability) hold even when network failures
prevent some machines from communicating with others

4
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

CAP Theorem
• Brewer’s CAP Theorem:
• For any system sharing data, it is “impossible” to guarantee simultaneously
all of these three properties
• You can have at most two of these three properties for any shared-data system
• Very large systems will “partition” at some point:
• That leaves either C or A to choose from (traditional DBMS prefers C over A
and P )
• In almost all cases, you would choose A over C (except in specific
applications such as order processing)

5
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

CAP Theorem
Consistency: All client
always have the same view of
Availability the data

Consistency

Partition
tolerance

6
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

CAP Theorem
• Consistency
• 2 types of consistency:
1. Strong consistency – ACID (Atomicity, Consistency, Isolation, Durability)
2. Weak consistency – BASE (Basically Available Soft-state Eventual
consistency)

7
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

CAP Theorem
• ACID
• A DBMS is expected to support “ACID transactions,” processes that are:
• Atomicity: either the whole process is done or none is
• Consistency: only valid data are written
• Isolation: one operation at a time
• Durability: once committed, it stays that way

• CAP
• Consistency: all data on cluster has the same copies
• Availability: cluster always accepts reads and writes
• Partition tolerance: guaranteed properties are maintained even when network
failures prevent some machines from communicating with others
8
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

CAP Theorem
• A consistency model determines rules for visibility and apparent order of
updates
• Example:
• Row X is replicated on nodes M and N
• Client A writes row X to node N
• Some period of time t elapses
• Client B reads row X from node M
• Does client B see the write from client A?
• Consistency is a field with tradeoffs
• For NOSQL, the answer would be: “maybe”
• CAP theorem states: “strong consistency can't be achieved at the same time as
availability and partition-tolerance”
9
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

CAP Theorem
• Eventual consistency
• When no updates occur for a long period of time, eventually all updates will propagate
through the system and all the nodes will be consistent
• Cloud computing
• ACID is hard to achieve, moreover, it is not always required, e.g. for blogs,
status updates, product listings, etc.

10
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

CAP Theorem
Availability:
Each client always can read
Availability and write.

Consistency

Partition
tolerance

11
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

CAP Theorem
Partition Tolerance:
A system can continue to
operate in the presence of
Availability a network partitions

Consistency

Partition
tolerance

12
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

Difference between SQL and NoSQL


Parameter SQL NOSQL
Definition SQL databases are primarily NoSQL databases are primarily called as
called RDBMS or Relational Non-relational or distributed database
Databases
Design for Traditional RDBMS uses SQL NoSQL database system consists of various
syntax and queries to analyze kind of database technologies. These
and get the data for further databases were developed in response to
insights. They are used for the demands presented for the
OLAP systems. development of the modern application.

Query Language Structured query language No declarative query language


(SQL)
Type SQL databases are table based NoSQL databases can be document based,
databases key-value pairs, graph databases
13

Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

Difference between SQL and NoSQL


Parameter SQL NOSQL
Schema SQL databases have a predefined NoSQL databases use dynamic
schema schema for unstructured data.
Ability to scale SQL databases are vertically scalable NoSQL databases are horizontally
scalable
Examples Oracle, Postgres, and MS-SQL. MongoDB, Redis, , Neo4j, Cassandra,
Hbase.
Best suited for An ideal choice for the complex query It is not good fit complex queries.
intensive environment.
Hierarchical data SQL databases are not suitable for More suitable for the hierarchical
storage hierarchical data storage. data store as it supports key-value
pair method.

14
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

Difference between SQL and NoSQL


Parameter SQL NOSQL
Variations One type with minor variations. Many different types which include key-value
stores, document databases, and graph
databases.

Development Year It was developed in the 1970s to deal Developed in the late 2000s to overcome issues
with issues with flat file storage and limitations of SQL databases.

Open-source A mix of open-source like Postgres & Open-source


MySQL, and commercial like Oracle
Database.

Consistency It should be configured for strong It depends on DBMS as some offers strong
consistency. consistency like MongoDB, whereas others offer
only offers eventual consistency, like Cassandra.

Best Used for RDBMS database is the right option for NoSQL is a best used for solving data availability
solving ACID problems. problems
15
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
Topic: NOSQL

Difference between SQL and NoSQL

Parameter SQL NOSQL


ACID vs. BASE ACID( Atomicity, Consistency, Base ( Basically Available, Soft
Model Isolation, and Durability) is a state, Eventually Consistent) is a
standard for RDBMS model of many NoSQL systems

16
Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: muneer.umar@kust.edu.pk
THANKS
Course: Database Management Systems (CS222)
Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST
Email: muneer.umar@kust.edu.pk

You might also like