Sei sulla pagina 1di 73

Introduction to NoSQL

babak.azarmi@yahoo.com

History

Future of NoSQL

1980

1990

2000

2010

Rise of Relational

The Value of Relational Databases

Getting at Persistent Data


Keeping large amounts of persistent data.
Notion of two areas of memory
Main memory
Backing store
Concurrency
Controlling all access to their data through transactions

The Value of Relational Databases

Integration
Shared database integration
Multiple applications store their data in a single database
A (Mostly) Standard Model
Developers & database professionals can learn the basic relational model and
Different vendors SQL dialects are similar, transactions operate in mostly the
Reporting

Impedance Mismatch

Future of NoSQL

1980

1990

2000

2010

Rise of Objective
Databases

Future of NoSQL

1980

1990

2000

2010

Relational Dominance

Impedance Mismatch

Definition
The difference between the relational model and the in-memory data structure.
The values in a relational row have to be simple. They cannot contain any struc
Solutions
Object-Oriented Databases (faded into obscurity due to hard integration)
Object-relational mapping frameworks (performance suffers)

Application and Integration Databases

The role of SQL as an integration mechanism betwee


Integration database with multiple applications
Sorting data in a common database
Operating applications on consistent set of persistent

Future of NoSQL

1980

1990

2000

2010

Relational Dominance

Attack of the Clusters

Lots of Traffic

Application and Integration Databases

Complex design for integrity


Indexing may cause problem hit on inserts because database u
Hard maintenance for changing (app layer / DB layer)
Internet and lots of traffic (Http / Web services)
Service Oriented Architecture leads to lacking of a consistent m
In XML, JSON you are able to put a rich structure of informatio
Text protocols are easy and binary protocols are fast.

Attack of the Clusters

Attack of the Clusters

More expensive
Providing low reliability
Relational databases are not designed to be run on cl
Losing any querying, referential integrity, transactions

Attack of the Clusters

The Emergence of NoSQL

Bigtable

Dynamo

Rise of NoSQL

NoSQL

London

San Francisco

John Oskarsson

Definition of NoSQL

Definition of NoSQL

There is no definition

Characteristics of NoSQL

Dont use SQL


Generally open source
Cluster-Friendly
Schema-less st
Build for the 21 century web estates
Non relational

Data Model

Document

Graph

Column-Family

Key-Value

Aggregate Data Models

Document (MangoDB,CouchDB,RavenDB)
Column-Family (Cassandra, Apache Hbase)
Key-Value (Riak,Redis)
Graph (Neo4j)

Key-Value Model

1256
4453

34352

65

Document Model
{"widget": {
"debug": "on",
"window": {
"title": "Sample Konfabulator Widget",
"name": "main_window",
"width": 500,
"height": 500
},
"image": {
"src": "Images/Sun.png",
"name": "sun1",
"hOffset": 250,
"vOffset": 250,
"alignment": "center"
},
"text": {
"data": "Click Here",
"size": 36,
"style": "bold",
"name": "text1",
"hOffset": 250,
"vOffset": 100,
"alignment": "center",
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
}
}}

Document Model

No Schema

<widget>
<debug>on</debug>
<window title="Sample Konfabulator Widget">
<name>main_window</name>
<width>500</width>
<height>500</height>
</window>
<image src="Images/Sun.png" name="sun1">
<hOffset>250</hOffset>
<vOffset>250</vOffset>
<alignment>center</alignment>
</image>
<text data="Click Here" size="36" style="bold">
<name>text1</name>
<hOffset>250</hOffset>
<vOffset>100</vOffset>
<alignment>center</alignment>
<onMouseUp>
sun1.opacity = (sun1.opacity / 100) * 90;
</onMouseUp>
</text>
</widget>

Document Model

Document vs Key-Value
Data in document model are very Transparent but
Retrieve and Save portion of document
Document vs Relational Model
Schema-less (scalability, Migration)

Key-Value Model

1256
1256
1256

Document Model

Key-Value Model

Document Model

Id=10

Customer Id = 43

Meta-data

Key

Aggregate-Oriented

Key-Value

Document

Eric Evans

Key-Value Model

Document Model

1256
1256
1256

Value == Aggregate

Document ==
Aggregate

Column-Family Model

AGGREGATE

Graph
Key-Value

Column-Family
Document

Graph Database

MATCH (p1:Person)-[r]->(p2:Person)
WHERE p1.name="Ali"
RETURN r,p2

Schema-less

Graph

Document

Key-Value

Column-Family

NoSQL & Consisten

Relational Databases == ACID

NoSQL == BASE

Atomic Update

Aggregate Oriented
Document
Column-Family
Key-Value

Graph is
ACID

Aggregate oriented databases dont need transaction as m


Big than more richer structure
DD says keep your transaction in a single aggregate
Any aggregates update is gonna be atomic.

ACID in RDBM doesnt mean completely Consisten

Browser
Server

Database

ACID in RDBM doesnt mean completely Consisten

ACID in RDBM doesnt mean completely Consisten

ACID in RDBM doesnt mean completely Consisten

ACID in RDBM doesnt mean completely Consisten

ACID in RDBM doesnt mean completely Consisten

Offline Lock

Give every record or aggregate data a version

Logical

Consistency

Replication

Replication Consistency Problem

Babak

Alex

Babak

Alex

Babak

Alex

Babak

Alex

Babak

Alex

Babak

Alex

Babak

Alex

Babak

Alex

Babak

Alex

Consistency
Availability

Babak

Alex

CAP Theorem

Consistency (all nodes see the same data at the sam


Availability (a guarantee that every request receives
Partition tolerance (the system continues to operate

Consistency

Partition

OR
Availability

Consistency

Response Time

Consistency in Aggregate-Oriented
Eventual Consistency
Relaxing durability
Quorums
Read-Your-Writes-Consistency

When & Why use NoSQL

Easier Development

NoSQL
Large Scale Data

Billing

Billing

Web Service

Inventory
Inventory

Future of NoSQL

1980

1990

2000

2010

Polyglot Persistence

User Management

Graph Database

Account Management

RDBMS

Problems

Decision
Organizational Change
Immaturity
Eventual Consistency

Potrebbero piacerti anche