NoSQL Databases
By Carlos Alberto Benitez - @betustwit
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.
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.
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.
Why NoSQL?
• More capacity for manage big data volume.
• Data can be stored and managed in different locations (Sharding).
• Exists many alternatives Open source.
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.
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
NoSQL Databases List
http://nosql-database.org
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
MongoDB - analogy
Relational DB MongoDB
Database Database
Tables Collections
Records Documents
Columns/fields Key-value pair
MongoDB - Document
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"
}
}
MongoDB - Sharding
Sharding is a method for storing data across multiple machines.
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
Redis DB - Persistence
RDB (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.
Redis DB – Persistence
AOF (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).
Redis DB - Data Types
Strings: 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.
Redis DB - Data Types
Sorted 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)
Redis DB - Replication
Redis 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>
By Carlos Alberto Benitez - @betustwit

NoSQL Databases

  • 1.
    NoSQL Databases By CarlosAlberto Benitez - @betustwit
  • 2.
    What is NoSQL? Relationaldatabases, 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.
  • 3.
    What is NoSQL? NoSQLtechnology 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.
  • 4.
    Why NoSQL? • Ismore 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.
  • 5.
    Why NoSQL? • Morecapacity for manage big data volume. • Data can be stored and managed in different locations (Sharding). • Exists many alternatives Open source.
  • 6.
    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.
  • 7.
    Types (Classified bydata 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
  • 8.
  • 9.
    MongoDB MongoDB is adocument 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
  • 10.
    MongoDB - analogy RelationalDB MongoDB Database Database Tables Collections Records Documents Columns/fields Key-value pair
  • 11.
  • 12.
    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" } }
  • 13.
    MongoDB - Sharding Shardingis a method for storing data across multiple machines.
  • 14.
    Redis DB Redis isan 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
  • 15.
    Redis DB -Persistence RDB (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.
  • 16.
    Redis DB –Persistence AOF (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).
  • 17.
    Redis DB -Data Types Strings: 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.
  • 18.
    Redis DB -Data Types Sorted 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)
  • 19.
    Redis DB -Replication Redis 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>
  • 20.
    By Carlos AlbertoBenitez - @betustwit