20
NoSQL Databases By Carlos Alberto Benitez - @betustwit

NoSQL Databases

Embed Size (px)

Citation preview

Page 1: NoSQL Databases

NoSQL Databases By Carlos Alberto Benitez - @betustwit

Page 2: NoSQL Databases

What is NoSQL?Relational databases, were not designed to work with the scale and

agility challenges that face modern applications, nor were they built to

take advantage of the storage and processing power available today.

NoSQL involves a wide variety of different database technologies that

were developed in response to a rise in the volume of data stored and

performance and processing needs.

Page 3: NoSQL Databases

What is NoSQL?NoSQL technology was pioneered by leading internet companies how

Google, Amazon, Facebook and LinkedIn.

NoSQL is frequently called Not Only SQL, since it is not always

necessary to use structured queries for data access.

The NoSQL was designed to store and manage large volume of data

with a response time of less than relational databases where the

read/write operations are very optimized.

Motivations for this approach include simplicity of design, horizontal

scaling and data availability.

Page 4: NoSQL Databases

Why NoSQL?• Is more efficient that Relational DB.

• Sharing and replication are simply.

• The NoSQL are more tolerant to fails.

• Focused to horizontal scalability.

• The relational model takes data and separates it into many

interrelated tables that contain rows and columns with one

structure defined, in NoSQL this is not necessary.

• Schema free (Dynamic schema).

• High data velocity (read/write optimizations).

• Allow storage of data that is structured, semi-structured and

unstructured.

Page 5: NoSQL Databases

Why NoSQL?• More capacity for manage big data volume.

• Data can be stored and managed in different locations (Sharding).

• Exists many alternatives Open source.

Page 6: NoSQL Databases

When use NoSQL?• NoSQL solves the performance of relational databases for handling

large volumes of data.

• NoSQL is especially useful when an enterprise needs to access and

analyze massive amounts of unstructured data.

Page 7: NoSQL Databases

Types (Classified by data store)Category DB Open Source

Column families

Cassandra Yes

Hypertable Yes

Hadoop Yes

Document

MongoDB Yes

CouchDB Yes

RavenDB Yes

Key-Value

Redis Yes

Riak Yes

DynamoDB No

Graph

Neo4j Yes

HyperGraphDB No

InfoGrid Yes

Object

Db4o Yes

EyeDB Yes

Perst Yes

Page 8: NoSQL Databases

NoSQL Databases Listhttp://nosql-database.org

Page 9: NoSQL Databases

MongoDB

MongoDB is a document database that provides high performance,

high availability and easy scalability.

Each element are stored how documents in collections.

MongoDB supports dynamic schema design, allowing the documents in

a collection to have different fields and structures.

Site: http://www.mongodb.org

Manual: http://docs.mongodb.org/manual

Page 10: NoSQL Databases

MongoDB - analogy

Relational DB MongoDB

Database Database

Tables Collections

Records Documents

Columns/fields Key-value pair

Page 11: NoSQL Databases

MongoDB - Document

Page 12: NoSQL Databases

MongoDB - Document{

title: "MongoDB: The Definitive Guide",

author: [ "Kristina Chodorow", "Mike Dirolf" ],

published_date: ISODate("2010-09-24"),

pages: 216,

language: "English",

publisher: {

name: "O'Reilly Media",

founded: 1980,

location: "CA"

}

}

Page 13: NoSQL Databases

MongoDB - Sharding

Sharding is a method for storing data across multiple machines.

Page 14: NoSQL Databases

Redis DB

Redis is an open source, advanced key-value cache and store. It is

often referred to as a data structure server since keys can contain

strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs.

Redis is an in-memory database.

Site: http://redis.io

Documentation: http://redis.io/documentation

Try Redis: http://try.redis.io

Page 15: NoSQL Databases

Redis DB - PersistenceRDB (Redis Data Base)

•The RDB persistence performs point-in-time snapshots of your

dataset at specified intervals.

•RDB is a very compact single-file (perfect for backups).

•RDB allows faster restarts with big datasets compared to AOF.

•RDB is NOT good for minimize the chance of data loss.

•The intervals can be configured on redis.conf file in the

SNAPSHOTTING section.

Page 16: NoSQL Databases

Redis DB – PersistenceAOF (Append Only File)

•The AOF logs every write operation received by the server.

•Commands are logged using the same format as the Redis protocol.

•It is possible to combine both AOF and RDB.

•The AOF log is an append only log (has not corruption problems if there

is a power outage).

•AOF contains a log of all the operations one after the other.

•AOF files are usually bigger than the equivalent RDB files for the same

dataset.

•Options: YES/NO (appendfsync: Always, Everysec, No).

Page 17: NoSQL Databases

Redis DB - Data TypesStrings: Are the most basic kind of Redis value, can contain any kind

of data, for instance a JPEG image. A String value can be at max 512

Megabytes in length.

Lists: Redis Lists are simply lists of strings, sorted by insertion order.

The max length of a list is 232 - 1 elements (more than 4 billion of

elements per list). Use: Model a timeline in a social network

Sets: Redis Sets are an unordered collection of Strings, Redis Sets

not allow repeated members. Is possible make unions, intersections,

differences of sets in very short time.

Page 18: NoSQL Databases

Redis DB - Data TypesSorted Sets: Are similarly to Sets, the difference is that every

member of a Sorted Set is associated with score, that is used in order

to take the sorted set ordered. Use: Search engine how Google based

on score for results.

Hashes: Are the most similar to relational database structure. Are

maps between string fields and string values, so they are the perfect

data type to represent objects (eg: A User with a number of fields like

name, surname, age, and so forth)

Page 19: NoSQL Databases

Redis DB - ReplicationRedis replication is a very simple to use and configure master-slave

replication that allows slave Redis servers to be exact copies of master

servers.

•Redis uses asynchronous replication.

•A master can have multiple slaves.

•Slaves are able to accept connections from other slaves.

•Replication is also non-blocking on the master and slave side.

Configuration (redis.conf -> REPLICATION)

slaveof <masterip> <masterport>

Page 20: NoSQL Databases

By Carlos Alberto Benitez - @betustwit