SlideShare a Scribd company logo
1 of 41
Database Applications (15-415)
Part I- NoSQL Databases
Lecture 26, April 21, 2015
Mohammad Hammoud
Today…
 Last Session:
 Recovery Management
 Today’s Session:
 NoSQL databases
 Announcements:
 PS4 grades are out
 On Thursday, April 23rd we will practice on Hive (during recitation)
 PS5 (the “last” assignment) is due on Thursday, April 23rd by midnight
 P4: Write a survey on SQL vs. NoSQL databases (optional)- due on
Friday, April 24th by midnight
 The final exam is on Monday April 27th, from 8:30AM to 11:30AM in
room 1190 (all materials are included- open book, open notes)
Outline
Types of Data
Scaling Databases & the 2PC Protocol
The CAP Theorem and the BASE
Properties
NoSQL Databases

Types of Data
 Data can be broadly classified into four types:
1. Structured Data:
 Have a predefined model, which organizes data into a
form that is relatively easy to store, process, retrieve
and manage
 E.g., relational data
2. Unstructured Data:
 Opposite of structured data
 E.g., Flat binary files containing text, video or audio
 Note: data is not completely devoid of a structure (e.g.,
an audio file may still have an encoding structure and
some metadata associated with it)
Types of Data
 Data can be broadly classified into four types:
3. Dynamic Data:
 Data that changes relatively frequently
 E.g., office documents and transactional entries in a
financial database
4. Static Data:
 Opposite of dynamic data
 E.g., Medical imaging data from MRI or CT scans
Why Classifying Data?
 Segmenting data into one of the following 4 quadrants can help in
designing and developing a pertaining storage solution
 Relational databases are usually used for structured data
 File systems or NoSQL databases can be used for (static),
unstructured data (more on these later)
Media Production, eCAD,
mCAD, Office Docs
Media Archive, Broadcast,
Medical Imaging
Transaction Systems, ERP,
CRM
BI, Data Warehousing
Dynamic
Unstructured
Structured
Static
Outline
Types of Data
Scaling Databases & the 2PC Protocol
The CAP Theorem and the BASE
Properties
NoSQL Databases

Scaling Traditional Databases
 Traditional RDBMSs can be either scaled:
 Vertically (or Up)
 Can be achieved by hardware upgrades (e.g., faster CPU,
more memory, or larger disk)
 Limited by the amount of CPU, RAM and disk that can be
configured on a single machine
 Horizontally (or Out)
 Can be achieved by adding more machines
 Requires database sharding and probably replication
 Limited by the Read-to-Write ratio and communication
overhead
Why Sharding Data?
 Data is typically sharded (or striped) to allow for
concurrent/parallel accesses
Input data: A large file
Machine 1
Chunk1 of input data
Machine 2
Chunk3 of input data
Machine 3
Chunk5 of input data
Chunk2 of input data Chunk4 of input data Chunk5 of input data
E.g., Chunks 1, 3 and 5 can be accessed in parallel
Amdahl’s Law
 How much faster will a parallel program run?
 Suppose that the sequential execution of a program takes T1 time
units and the parallel execution on p processors/machines takes
Tp time units
 Suppose that out of the entire execution of the program, s
fraction of it is not parallelizable while 1-s fraction is parallelizable
 Then the speedup (Amdahl’s formula):
10
Amdahl’s Law: An Example
 Suppose that:
 80% of your program can be parallelized
 4 machines are used to run your parallel version of
the program
 The speedup you can get according to Amdahl’s law is:
11
Although you use 4 processors you cannot get a speedup more
than 2.5 times!
Real Vs. Actual Cases
 Amdahl’s argument is too simplified
 In reality, communication overhead and potential workload
imbalance exist upon running parallel programs
20 80
20 20
Process 1
Process 2
Process 3
Process 4
Serial
Parallel
1. Parallel Speed-up: An Ideal Case
Cannot be parallelized
Can be parallelized
20 80
20 20
Process 1
Process 2
Process 3
Process 4
Serial
Parallel
2. Parallel Speed-up: An Actual Case
Cannot be parallelized
Can be parallelized
Load Unbalance
Communication overhead
Some Guidelines
 Here are some guidelines to effectively benefit
from parallelization:
1. Maximize the fraction of your program that can
be parallelized
2. Balance the workload of parallel processes
3. Minimize the time spent for communication
13
Why Replicating Data?
 Replicating data across servers helps in:
 Avoiding performance bottlenecks
 Avoiding single point of failures
 And, hence, enhancing scalability and availability
Why Replicating Data?
 Replicating data across servers helps in:
 Avoiding performance bottlenecks
 Avoiding single point of failures
 And, hence, enhancing scalability and availability
Main Server
Replicated Servers
But, Consistency Becomes a Challenge
 An example:
 In an e-commerce application, the bank database has
been replicated across two servers
 Maintaining consistency of replicated data is a challenge
Bal=1000 Bal=1000
Replicated Database
Event 1 = Add $1000 Event 2 = Add interest of 5%
Bal=2000
1 2
Bal=1050
3 Bal=2050
4
Bal=2100
The Two-Phase Commit Protocol
 The two-phase commit protocol (2PC) can be used to
ensure atomicity and consistency
Database Server 1
Participant 1
Coordinator Database Server 2
Participant 2
Database Server 3
Participant 3
VOTE_REQUEST
VOTE_REQUEST
VOTE_REQUEST
Phase I: Voting
VOTE_COMMIT
VOTE_COMMIT
VOTE_COMMIT
The Two-Phase Commit Protocol
 The two-phase commit protocol (2PC) can be used to
ensure atomicity and consistency
Database Server 1
Participant 1
Coordinator Database Server 2
Participant 2
Database Server 3
Participant 3
GLOBAL_COMMIT
GLOBAL_COMMIT
GLOBAL_COMMIT
Phase II: Commit
LOCAL_COMMIT
LOCAL_COMMIT
LOCAL_COMMIT
“Strict” consistency, which
limits scalability!
Outline
Types of Data
Scaling Databases & the 2PC Protocol
The CAP Theorem and the BASE
Properties
NoSQL Databases

The CAP Theorem
 The limitations of distributed databases can be described
in the so called the CAP theorem
 Consistency: every node always sees the same data at any
given instance (i.e., strict consistency)
 Availability: the system continues to operate, even if nodes
in a cluster crash, or some hardware or software parts are
down due to upgrades
 Partition Tolerance: the system continues to operate in the
presence of network partitions
CAP theorem: any distributed database with shared data, can have at most two
of the three desirable properties, C, A or P
The CAP Theorem (Cont’d)
 Let us assume two nodes on opposite sides of a
network partition:
 Availability + Partition Tolerance forfeit Consistency
 Consistency + Partition Tolerance entails that one side of
the partition must act as if it is unavailable, thus
forfeiting Availability
 Consistency + Availability is only possible if there is no
network partition, thereby forfeiting Partition Tolerance
Large-Scale Databases
 When companies such as Google and Amazon were
designing large-scale databases, 24/7 Availability was a key
 A few minutes of downtime means lost revenue
 When horizontally scaling databases to 1000s of machines,
the likelihood of a node or a network failure
increases tremendously
 Therefore, in order to have strong guarantees on
Availability and Partition Tolerance, they had to sacrifice
“strict” Consistency (implied by the CAP theorem)
Trading-Off Consistency
 Maintaining consistency should balance between the
strictness of consistency versus availability/scalability
 Good-enough consistency depends on your application
Trading-Off Consistency
 Maintaining consistency should balance between the
strictness of consistency versus availability/scalability
 Good-enough consistency depends on your application
Strict Consistency
Generally hard to implement,
and is inefficient
Loose Consistency
Easier to implement,
and is efficient
The BASE Properties
 The CAP theorem proves that it is impossible to guarantee
strict Consistency and Availability while being able to
tolerate network partitions
 This resulted in databases with relaxed ACID guarantees
 In particular, such databases apply the BASE properties:
 Basically Available: the system guarantees Availability
 Soft-State: the state of the system may change over time
 Eventual Consistency: the system will eventually
become consistent
Eventual Consistency
 A database is termed as Eventually Consistent if:
 All replicas will gradually become consistent in the
absence of updates
Eventual Consistency
 A database is termed as Eventually Consistent if:
 All replicas will gradually become consistent in the
absence of updates
Webpage-A
Event: Update Webpage-
A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Eventual Consistency:
A Main Challenge
 But, what if the client accesses the data from
different replicas?
Webpage-A
Event: Update Webpage-
A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Webpage-A
Protocols like Read Your Own Writes (RYOW) can be applied!
Outline
Types of Data
Scaling Databases & the 2PC Protocol
The CAP Theorem and the BASE
Properties
NoSQL Databases

NoSQL Databases
 To this end, a new class of databases emerged, which
mainly follow the BASE properties
 These were dubbed as NoSQL databases
 E.g., Amazon’s Dynamo and Google’s Bigtable
 Main characteristics of NoSQL databases include:
 No strict schema requirements
 No strict adherence to ACID properties
 Consistency is traded in favor of Availability
Types of NoSQL Databases
 Here is a limited taxonomy of NoSQL databases:
NoSQL Databases
Document
Stores
Graph
Databases
Key-Value
Stores
Columnar
Databases
Document Stores
 Documents are stored in some standard format or
encoding (e.g., XML, JSON, PDF or Office Documents)
 These are typically referred to as Binary Large Objects
(BLOBs)
 Documents can be indexed
 This allows document stores to outperform traditional
file systems
 E.g., MongoDB and CouchDB (both can be queried
using MapReduce)
Types of NoSQL Databases
 Here is a limited taxonomy of NoSQL databases:
NoSQL Databases
Document
Stores
Graph
Databases
Key-Value
Stores
Columnar
Databases
Graph Databases
 Data are represented as vertices and edges
 Graph databases are powerful for graph-like queries (e.g., find
the shortest path between two elements)
 E.g., Neo4j and VertexDB
Id: 1
Name: Alice
Age: 18
Id: 2
Name: Bob
Age: 22
Id: 3
Name: Chess
Type: Group
Types of NoSQL Databases
 Here is a limited taxonomy of NoSQL databases:
NoSQL Databases
Document
Stores
Graph
Databases
Key-Value
Stores
Columnar
Databases
Key-Value Stores
 Keys are mapped to (possibly) more complex value
(e.g., lists)
 Keys can be stored in a hash table and can be
distributed easily
 Such stores typically support regular CRUD (create,
read, update, and delete) operations
 That is, no joins and aggregate functions
 E.g., Amazon DynamoDB and Apache Cassandra
Types of NoSQL Databases
 Here is a limited taxonomy of NoSQL databases:
NoSQL Databases
Document
Stores
Graph
Databases
Key-Value
Stores
Columnar
Databases
Columnar Databases
 Columnar databases are a hybrid of RDBMSs and Key-
Value stores
 Values are stored in groups of zero or more columns, but in
Column-Order (as opposed to Row-Order)
 Values are queried by matching keys
 E.g., HBase and Vertica
Alice 3 25 Bob
4 19 Carol 0
45
Record 1
Row-Order
Alice
3 25
Bob
4
19
Carol
0
45
Column A
Columnar (or Column-Order)
Alice
3 25
Bob
4 19
Carol
0 45
Columnar with Locality Groups
Column A = Group A
Column Family {B, C}
Summary
 Data can be classified into 4 types, structured,
unstructured, dynamic and static
 Different data types usually entail different database
designs
 Databases can be scaled up or out
 The 2PC protocol can be used to ensure strict
consistency
 Strict consistency limits scalability
Summary (Cont’d)
 The CAP theorem states that any distributed
database with shared data can have at most two
of the three desirable properties:
 Consistency
 Availability
 Partition Tolerance
 The CAP theorem lead to various designs of
databases with relaxed ACID guarantees
Summary (Cont’d)
 NoSQL (or Not-Only-SQL) databases follow the BASE
properties:
 Basically Available
 Soft-State
 Eventual Consistency
 NoSQL databases have different types:
 Document Stores
 Graph Databases
 Key-Value Stores
 Columnar Databases

More Related Content

Similar to NoSQL

Google Cloud Computing on Google Developer 2008 Day
Google Cloud Computing on Google Developer 2008 DayGoogle Cloud Computing on Google Developer 2008 Day
Google Cloud Computing on Google Developer 2008 Dayprogrammermag
 
Tales From The Front: An Architecture For Multi-Data Center Scalable Applicat...
Tales From The Front: An Architecture For Multi-Data Center Scalable Applicat...Tales From The Front: An Architecture For Multi-Data Center Scalable Applicat...
Tales From The Front: An Architecture For Multi-Data Center Scalable Applicat...DataStax Academy
 
Bhupeshbansal bigdata
Bhupeshbansal bigdata Bhupeshbansal bigdata
Bhupeshbansal bigdata Bhupesh Bansal
 
Knowledge share about scalable application architecture
Knowledge share about scalable application architectureKnowledge share about scalable application architecture
Knowledge share about scalable application architectureAHM Pervej Kabir
 
Petabytes and Nanoseconds
Petabytes and NanosecondsPetabytes and Nanoseconds
Petabytes and NanosecondsRobert Greiner
 
LIQUID-A Scalable Deduplication File System For Virtual Machine Images
LIQUID-A Scalable Deduplication File System For Virtual Machine ImagesLIQUID-A Scalable Deduplication File System For Virtual Machine Images
LIQUID-A Scalable Deduplication File System For Virtual Machine Imagesfabna benz
 
DB2 for z/O S Data Sharing
DB2 for z/O S  Data  SharingDB2 for z/O S  Data  Sharing
DB2 for z/O S Data SharingSurekha Parekh
 
Virtual Storage Center
Virtual Storage CenterVirtual Storage Center
Virtual Storage CenterIBM Danmark
 
Introduction to Couchbase
Introduction to CouchbaseIntroduction to Couchbase
Introduction to CouchbaseMohammad Shaker
 
Architecting and Tuning IIB/eXtreme Scale for Maximum Performance and Reliabi...
Architecting and Tuning IIB/eXtreme Scale for Maximum Performance and Reliabi...Architecting and Tuning IIB/eXtreme Scale for Maximum Performance and Reliabi...
Architecting and Tuning IIB/eXtreme Scale for Maximum Performance and Reliabi...Prolifics
 
Windows Azure: Lessons From The Field
Windows Azure: Lessons From The FieldWindows Azure: Lessons From The Field
Windows Azure: Lessons From The FieldRob Gillen
 
Building High Performance MySQL Query Systems and Analytic Applications
Building High Performance MySQL Query Systems and Analytic ApplicationsBuilding High Performance MySQL Query Systems and Analytic Applications
Building High Performance MySQL Query Systems and Analytic ApplicationsCalpont
 
Building High Performance MySql Query Systems And Analytic Applications
Building High Performance MySql Query Systems And Analytic ApplicationsBuilding High Performance MySql Query Systems And Analytic Applications
Building High Performance MySql Query Systems And Analytic Applicationsguest40cda0b
 
Compare Clustering Methods for MS SQL Server
Compare Clustering Methods for MS SQL ServerCompare Clustering Methods for MS SQL Server
Compare Clustering Methods for MS SQL ServerAlexDepo
 
Building the Perfect SharePoint 2010 Farm - SPS Brisbane 2011
Building the Perfect SharePoint 2010 Farm - SPS Brisbane 2011Building the Perfect SharePoint 2010 Farm - SPS Brisbane 2011
Building the Perfect SharePoint 2010 Farm - SPS Brisbane 2011Michael Noel
 
Vargas polyglot-persistence-cloud-edbt
Vargas polyglot-persistence-cloud-edbtVargas polyglot-persistence-cloud-edbt
Vargas polyglot-persistence-cloud-edbtGenoveva Vargas-Solar
 
Cio Breakfast Roundtable 05142009 Final Virtualization
Cio Breakfast Roundtable 05142009 Final VirtualizationCio Breakfast Roundtable 05142009 Final Virtualization
Cio Breakfast Roundtable 05142009 Final Virtualizationguestc900809
 
Distributed Systems: scalability and high availability
Distributed Systems: scalability and high availabilityDistributed Systems: scalability and high availability
Distributed Systems: scalability and high availabilityRenato Lucindo
 
NoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, ImplementationsNoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, ImplementationsFirat Atagun
 

Similar to NoSQL (20)

Google Cloud Computing on Google Developer 2008 Day
Google Cloud Computing on Google Developer 2008 DayGoogle Cloud Computing on Google Developer 2008 Day
Google Cloud Computing on Google Developer 2008 Day
 
Tales From The Front: An Architecture For Multi-Data Center Scalable Applicat...
Tales From The Front: An Architecture For Multi-Data Center Scalable Applicat...Tales From The Front: An Architecture For Multi-Data Center Scalable Applicat...
Tales From The Front: An Architecture For Multi-Data Center Scalable Applicat...
 
Bhupeshbansal bigdata
Bhupeshbansal bigdata Bhupeshbansal bigdata
Bhupeshbansal bigdata
 
Knowledge share about scalable application architecture
Knowledge share about scalable application architectureKnowledge share about scalable application architecture
Knowledge share about scalable application architecture
 
Petabytes and Nanoseconds
Petabytes and NanosecondsPetabytes and Nanoseconds
Petabytes and Nanoseconds
 
LIQUID-A Scalable Deduplication File System For Virtual Machine Images
LIQUID-A Scalable Deduplication File System For Virtual Machine ImagesLIQUID-A Scalable Deduplication File System For Virtual Machine Images
LIQUID-A Scalable Deduplication File System For Virtual Machine Images
 
DB2 for z/O S Data Sharing
DB2 for z/O S  Data  SharingDB2 for z/O S  Data  Sharing
DB2 for z/O S Data Sharing
 
Virtual Storage Center
Virtual Storage CenterVirtual Storage Center
Virtual Storage Center
 
Introduction to Couchbase
Introduction to CouchbaseIntroduction to Couchbase
Introduction to Couchbase
 
Architecting and Tuning IIB/eXtreme Scale for Maximum Performance and Reliabi...
Architecting and Tuning IIB/eXtreme Scale for Maximum Performance and Reliabi...Architecting and Tuning IIB/eXtreme Scale for Maximum Performance and Reliabi...
Architecting and Tuning IIB/eXtreme Scale for Maximum Performance and Reliabi...
 
Windows Azure: Lessons From The Field
Windows Azure: Lessons From The FieldWindows Azure: Lessons From The Field
Windows Azure: Lessons From The Field
 
Building High Performance MySQL Query Systems and Analytic Applications
Building High Performance MySQL Query Systems and Analytic ApplicationsBuilding High Performance MySQL Query Systems and Analytic Applications
Building High Performance MySQL Query Systems and Analytic Applications
 
Building High Performance MySql Query Systems And Analytic Applications
Building High Performance MySql Query Systems And Analytic ApplicationsBuilding High Performance MySql Query Systems And Analytic Applications
Building High Performance MySql Query Systems And Analytic Applications
 
Compare Clustering Methods for MS SQL Server
Compare Clustering Methods for MS SQL ServerCompare Clustering Methods for MS SQL Server
Compare Clustering Methods for MS SQL Server
 
Building the Perfect SharePoint 2010 Farm - SPS Brisbane 2011
Building the Perfect SharePoint 2010 Farm - SPS Brisbane 2011Building the Perfect SharePoint 2010 Farm - SPS Brisbane 2011
Building the Perfect SharePoint 2010 Farm - SPS Brisbane 2011
 
Vargas polyglot-persistence-cloud-edbt
Vargas polyglot-persistence-cloud-edbtVargas polyglot-persistence-cloud-edbt
Vargas polyglot-persistence-cloud-edbt
 
Cio Breakfast Roundtable 05142009 Final Virtualization
Cio Breakfast Roundtable 05142009 Final VirtualizationCio Breakfast Roundtable 05142009 Final Virtualization
Cio Breakfast Roundtable 05142009 Final Virtualization
 
Distributed Systems: scalability and high availability
Distributed Systems: scalability and high availabilityDistributed Systems: scalability and high availability
Distributed Systems: scalability and high availability
 
Csc concepts
Csc conceptsCsc concepts
Csc concepts
 
NoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, ImplementationsNoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, Implementations
 

More from RithikRaj25

More from RithikRaj25 (17)

html1.ppt
html1.ppthtml1.ppt
html1.ppt
 
Data
DataData
Data
 
Data
DataData
Data
 
Introduction To Database.ppt
Introduction To Database.pptIntroduction To Database.ppt
Introduction To Database.ppt
 
Data.ppt
Data.pptData.ppt
Data.ppt
 
DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
 
NoSQL.pptx
NoSQL.pptxNoSQL.pptx
NoSQL.pptx
 
text classification_NB.ppt
text classification_NB.ppttext classification_NB.ppt
text classification_NB.ppt
 
html1.ppt
html1.ppthtml1.ppt
html1.ppt
 
slide-keras-tf.pptx
slide-keras-tf.pptxslide-keras-tf.pptx
slide-keras-tf.pptx
 
Intro_OpenCV.ppt
Intro_OpenCV.pptIntro_OpenCV.ppt
Intro_OpenCV.ppt
 
lec1b.ppt
lec1b.pptlec1b.ppt
lec1b.ppt
 
PR7.ppt
PR7.pptPR7.ppt
PR7.ppt
 
objectdetect_tutorial.ppt
objectdetect_tutorial.pptobjectdetect_tutorial.ppt
objectdetect_tutorial.ppt
 
14_ReinforcementLearning.pptx
14_ReinforcementLearning.pptx14_ReinforcementLearning.pptx
14_ReinforcementLearning.pptx
 
datamining-lect11.pptx
datamining-lect11.pptxdatamining-lect11.pptx
datamining-lect11.pptx
 
week6a.ppt
week6a.pptweek6a.ppt
week6a.ppt
 

Recently uploaded

➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...amitlee9823
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
hybrid Seed Production In Chilli & Capsicum.pptx
hybrid Seed Production In Chilli & Capsicum.pptxhybrid Seed Production In Chilli & Capsicum.pptx
hybrid Seed Production In Chilli & Capsicum.pptx9to5mart
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...amitlee9823
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...only4webmaster01
 
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...amitlee9823
 
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...amitlee9823
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
➥🔝 7737669865 🔝▻ Thrissur Call-girls in Women Seeking Men 🔝Thrissur🔝 Escor...
➥🔝 7737669865 🔝▻ Thrissur Call-girls in Women Seeking Men  🔝Thrissur🔝   Escor...➥🔝 7737669865 🔝▻ Thrissur Call-girls in Women Seeking Men  🔝Thrissur🔝   Escor...
➥🔝 7737669865 🔝▻ Thrissur Call-girls in Women Seeking Men 🔝Thrissur🔝 Escor...amitlee9823
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsJoseMangaJr1
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...amitlee9823
 
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night StandCall Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...karishmasinghjnh
 

Recently uploaded (20)

➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
hybrid Seed Production In Chilli & Capsicum.pptx
hybrid Seed Production In Chilli & Capsicum.pptxhybrid Seed Production In Chilli & Capsicum.pptx
hybrid Seed Production In Chilli & Capsicum.pptx
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
 
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
 
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
➥🔝 7737669865 🔝▻ Thrissur Call-girls in Women Seeking Men 🔝Thrissur🔝 Escor...
➥🔝 7737669865 🔝▻ Thrissur Call-girls in Women Seeking Men  🔝Thrissur🔝   Escor...➥🔝 7737669865 🔝▻ Thrissur Call-girls in Women Seeking Men  🔝Thrissur🔝   Escor...
➥🔝 7737669865 🔝▻ Thrissur Call-girls in Women Seeking Men 🔝Thrissur🔝 Escor...
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
 
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
 
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night StandCall Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
 
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
 

NoSQL

  • 1. Database Applications (15-415) Part I- NoSQL Databases Lecture 26, April 21, 2015 Mohammad Hammoud
  • 2. Today…  Last Session:  Recovery Management  Today’s Session:  NoSQL databases  Announcements:  PS4 grades are out  On Thursday, April 23rd we will practice on Hive (during recitation)  PS5 (the “last” assignment) is due on Thursday, April 23rd by midnight  P4: Write a survey on SQL vs. NoSQL databases (optional)- due on Friday, April 24th by midnight  The final exam is on Monday April 27th, from 8:30AM to 11:30AM in room 1190 (all materials are included- open book, open notes)
  • 3. Outline Types of Data Scaling Databases & the 2PC Protocol The CAP Theorem and the BASE Properties NoSQL Databases 
  • 4. Types of Data  Data can be broadly classified into four types: 1. Structured Data:  Have a predefined model, which organizes data into a form that is relatively easy to store, process, retrieve and manage  E.g., relational data 2. Unstructured Data:  Opposite of structured data  E.g., Flat binary files containing text, video or audio  Note: data is not completely devoid of a structure (e.g., an audio file may still have an encoding structure and some metadata associated with it)
  • 5. Types of Data  Data can be broadly classified into four types: 3. Dynamic Data:  Data that changes relatively frequently  E.g., office documents and transactional entries in a financial database 4. Static Data:  Opposite of dynamic data  E.g., Medical imaging data from MRI or CT scans
  • 6. Why Classifying Data?  Segmenting data into one of the following 4 quadrants can help in designing and developing a pertaining storage solution  Relational databases are usually used for structured data  File systems or NoSQL databases can be used for (static), unstructured data (more on these later) Media Production, eCAD, mCAD, Office Docs Media Archive, Broadcast, Medical Imaging Transaction Systems, ERP, CRM BI, Data Warehousing Dynamic Unstructured Structured Static
  • 7. Outline Types of Data Scaling Databases & the 2PC Protocol The CAP Theorem and the BASE Properties NoSQL Databases 
  • 8. Scaling Traditional Databases  Traditional RDBMSs can be either scaled:  Vertically (or Up)  Can be achieved by hardware upgrades (e.g., faster CPU, more memory, or larger disk)  Limited by the amount of CPU, RAM and disk that can be configured on a single machine  Horizontally (or Out)  Can be achieved by adding more machines  Requires database sharding and probably replication  Limited by the Read-to-Write ratio and communication overhead
  • 9. Why Sharding Data?  Data is typically sharded (or striped) to allow for concurrent/parallel accesses Input data: A large file Machine 1 Chunk1 of input data Machine 2 Chunk3 of input data Machine 3 Chunk5 of input data Chunk2 of input data Chunk4 of input data Chunk5 of input data E.g., Chunks 1, 3 and 5 can be accessed in parallel
  • 10. Amdahl’s Law  How much faster will a parallel program run?  Suppose that the sequential execution of a program takes T1 time units and the parallel execution on p processors/machines takes Tp time units  Suppose that out of the entire execution of the program, s fraction of it is not parallelizable while 1-s fraction is parallelizable  Then the speedup (Amdahl’s formula): 10
  • 11. Amdahl’s Law: An Example  Suppose that:  80% of your program can be parallelized  4 machines are used to run your parallel version of the program  The speedup you can get according to Amdahl’s law is: 11 Although you use 4 processors you cannot get a speedup more than 2.5 times!
  • 12. Real Vs. Actual Cases  Amdahl’s argument is too simplified  In reality, communication overhead and potential workload imbalance exist upon running parallel programs 20 80 20 20 Process 1 Process 2 Process 3 Process 4 Serial Parallel 1. Parallel Speed-up: An Ideal Case Cannot be parallelized Can be parallelized 20 80 20 20 Process 1 Process 2 Process 3 Process 4 Serial Parallel 2. Parallel Speed-up: An Actual Case Cannot be parallelized Can be parallelized Load Unbalance Communication overhead
  • 13. Some Guidelines  Here are some guidelines to effectively benefit from parallelization: 1. Maximize the fraction of your program that can be parallelized 2. Balance the workload of parallel processes 3. Minimize the time spent for communication 13
  • 14. Why Replicating Data?  Replicating data across servers helps in:  Avoiding performance bottlenecks  Avoiding single point of failures  And, hence, enhancing scalability and availability
  • 15. Why Replicating Data?  Replicating data across servers helps in:  Avoiding performance bottlenecks  Avoiding single point of failures  And, hence, enhancing scalability and availability Main Server Replicated Servers
  • 16. But, Consistency Becomes a Challenge  An example:  In an e-commerce application, the bank database has been replicated across two servers  Maintaining consistency of replicated data is a challenge Bal=1000 Bal=1000 Replicated Database Event 1 = Add $1000 Event 2 = Add interest of 5% Bal=2000 1 2 Bal=1050 3 Bal=2050 4 Bal=2100
  • 17. The Two-Phase Commit Protocol  The two-phase commit protocol (2PC) can be used to ensure atomicity and consistency Database Server 1 Participant 1 Coordinator Database Server 2 Participant 2 Database Server 3 Participant 3 VOTE_REQUEST VOTE_REQUEST VOTE_REQUEST Phase I: Voting VOTE_COMMIT VOTE_COMMIT VOTE_COMMIT
  • 18. The Two-Phase Commit Protocol  The two-phase commit protocol (2PC) can be used to ensure atomicity and consistency Database Server 1 Participant 1 Coordinator Database Server 2 Participant 2 Database Server 3 Participant 3 GLOBAL_COMMIT GLOBAL_COMMIT GLOBAL_COMMIT Phase II: Commit LOCAL_COMMIT LOCAL_COMMIT LOCAL_COMMIT “Strict” consistency, which limits scalability!
  • 19. Outline Types of Data Scaling Databases & the 2PC Protocol The CAP Theorem and the BASE Properties NoSQL Databases 
  • 20. The CAP Theorem  The limitations of distributed databases can be described in the so called the CAP theorem  Consistency: every node always sees the same data at any given instance (i.e., strict consistency)  Availability: the system continues to operate, even if nodes in a cluster crash, or some hardware or software parts are down due to upgrades  Partition Tolerance: the system continues to operate in the presence of network partitions CAP theorem: any distributed database with shared data, can have at most two of the three desirable properties, C, A or P
  • 21. The CAP Theorem (Cont’d)  Let us assume two nodes on opposite sides of a network partition:  Availability + Partition Tolerance forfeit Consistency  Consistency + Partition Tolerance entails that one side of the partition must act as if it is unavailable, thus forfeiting Availability  Consistency + Availability is only possible if there is no network partition, thereby forfeiting Partition Tolerance
  • 22. Large-Scale Databases  When companies such as Google and Amazon were designing large-scale databases, 24/7 Availability was a key  A few minutes of downtime means lost revenue  When horizontally scaling databases to 1000s of machines, the likelihood of a node or a network failure increases tremendously  Therefore, in order to have strong guarantees on Availability and Partition Tolerance, they had to sacrifice “strict” Consistency (implied by the CAP theorem)
  • 23. Trading-Off Consistency  Maintaining consistency should balance between the strictness of consistency versus availability/scalability  Good-enough consistency depends on your application
  • 24. Trading-Off Consistency  Maintaining consistency should balance between the strictness of consistency versus availability/scalability  Good-enough consistency depends on your application Strict Consistency Generally hard to implement, and is inefficient Loose Consistency Easier to implement, and is efficient
  • 25. The BASE Properties  The CAP theorem proves that it is impossible to guarantee strict Consistency and Availability while being able to tolerate network partitions  This resulted in databases with relaxed ACID guarantees  In particular, such databases apply the BASE properties:  Basically Available: the system guarantees Availability  Soft-State: the state of the system may change over time  Eventual Consistency: the system will eventually become consistent
  • 26. Eventual Consistency  A database is termed as Eventually Consistent if:  All replicas will gradually become consistent in the absence of updates
  • 27. Eventual Consistency  A database is termed as Eventually Consistent if:  All replicas will gradually become consistent in the absence of updates Webpage-A Event: Update Webpage- A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A
  • 28. Eventual Consistency: A Main Challenge  But, what if the client accesses the data from different replicas? Webpage-A Event: Update Webpage- A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Webpage-A Protocols like Read Your Own Writes (RYOW) can be applied!
  • 29. Outline Types of Data Scaling Databases & the 2PC Protocol The CAP Theorem and the BASE Properties NoSQL Databases 
  • 30. NoSQL Databases  To this end, a new class of databases emerged, which mainly follow the BASE properties  These were dubbed as NoSQL databases  E.g., Amazon’s Dynamo and Google’s Bigtable  Main characteristics of NoSQL databases include:  No strict schema requirements  No strict adherence to ACID properties  Consistency is traded in favor of Availability
  • 31. Types of NoSQL Databases  Here is a limited taxonomy of NoSQL databases: NoSQL Databases Document Stores Graph Databases Key-Value Stores Columnar Databases
  • 32. Document Stores  Documents are stored in some standard format or encoding (e.g., XML, JSON, PDF or Office Documents)  These are typically referred to as Binary Large Objects (BLOBs)  Documents can be indexed  This allows document stores to outperform traditional file systems  E.g., MongoDB and CouchDB (both can be queried using MapReduce)
  • 33. Types of NoSQL Databases  Here is a limited taxonomy of NoSQL databases: NoSQL Databases Document Stores Graph Databases Key-Value Stores Columnar Databases
  • 34. Graph Databases  Data are represented as vertices and edges  Graph databases are powerful for graph-like queries (e.g., find the shortest path between two elements)  E.g., Neo4j and VertexDB Id: 1 Name: Alice Age: 18 Id: 2 Name: Bob Age: 22 Id: 3 Name: Chess Type: Group
  • 35. Types of NoSQL Databases  Here is a limited taxonomy of NoSQL databases: NoSQL Databases Document Stores Graph Databases Key-Value Stores Columnar Databases
  • 36. Key-Value Stores  Keys are mapped to (possibly) more complex value (e.g., lists)  Keys can be stored in a hash table and can be distributed easily  Such stores typically support regular CRUD (create, read, update, and delete) operations  That is, no joins and aggregate functions  E.g., Amazon DynamoDB and Apache Cassandra
  • 37. Types of NoSQL Databases  Here is a limited taxonomy of NoSQL databases: NoSQL Databases Document Stores Graph Databases Key-Value Stores Columnar Databases
  • 38. Columnar Databases  Columnar databases are a hybrid of RDBMSs and Key- Value stores  Values are stored in groups of zero or more columns, but in Column-Order (as opposed to Row-Order)  Values are queried by matching keys  E.g., HBase and Vertica Alice 3 25 Bob 4 19 Carol 0 45 Record 1 Row-Order Alice 3 25 Bob 4 19 Carol 0 45 Column A Columnar (or Column-Order) Alice 3 25 Bob 4 19 Carol 0 45 Columnar with Locality Groups Column A = Group A Column Family {B, C}
  • 39. Summary  Data can be classified into 4 types, structured, unstructured, dynamic and static  Different data types usually entail different database designs  Databases can be scaled up or out  The 2PC protocol can be used to ensure strict consistency  Strict consistency limits scalability
  • 40. Summary (Cont’d)  The CAP theorem states that any distributed database with shared data can have at most two of the three desirable properties:  Consistency  Availability  Partition Tolerance  The CAP theorem lead to various designs of databases with relaxed ACID guarantees
  • 41. Summary (Cont’d)  NoSQL (or Not-Only-SQL) databases follow the BASE properties:  Basically Available  Soft-State  Eventual Consistency  NoSQL databases have different types:  Document Stores  Graph Databases  Key-Value Stores  Columnar Databases