Lec 17 Nosql
Lec 17 Nosql
2
School of Computer Engineering
Database
Database
RDBMS NoSQL
OLAP OLTP
3
School of Computer Engineering
OLTP vs. OLAP
OLTP OLAP
Many short transactions Long transactions, complex queries
Example: Example:
‐ Update account balance ‐ Count the classes with fewer than 10 classes
‐ Add book to shopping cart ‐ Report total sales for each dept in each month
‐ Enroll in course
Queries touch small amounts of data Queries touch large amounts of data
(few records)
Updates are frequent Updates are infrequent
Concurrency is biggest performance Individual queries can require lots of resources
problem
4
School of Computer Engineering
NoSQL
NoSQL database stands for "Not Only SQL" or "Not SQL."
It is a non-relational database, that does not require a fixed schema, and avoids joins.
It is used for distributed data stores and specifically targeted for Big Data, for
example Google or Facebook which collects terabytes of data every day for their
users.
Traditional RDBMS uses SQL syntax to store and retrieve data for further insights.
Instead, a NoSQL database system encompasses a wide range of database
technologies that can store structured, semi-structured, and unstructured data.
It adhere to Brewer’s CAP theorem.
The tables are stored as ASCII files and each field is separated by tabs
The data scale horizontally.
5
School of Computer Engineering
Why and Uses of NoSQL
Why: In today’s time data is becoming easier to access and capture through
third parties such as Facebook, Google+ and others. Personal user information,
social graphs, geo location data, user-generated content and machine logging
data are just a few examples where the data has been increasing exponentially.
To avail the above service properly, it is required to process huge amount of data
which SQL databases were never designed. The evolution of NoSql databases is
to handle these huge data properly.
Uses:
Log analysis
Time‐based data
6
School of Computer Engineering
Types of NoSQL Database
There are mainly four categories of NoSQL databases. Each of these categories
has its unique attributes and limitations.
9
School of Computer Engineering
JSON vs. XML format
10
School of Computer Engineering
Column‐Oriented vs. Row‐Oriented Database
11
School of Computer Engineering
Column‐Oriented vs. Row‐Oriented Database cont’d
Records in Row Oriented Data stores are easy to In this type of data stores, read and write
read and write. operations are slower as compared to row‐
oriented.
Row‐oriented data stores are best suited for online Column‐oriented stores are best suited for online
transaction system. analytical processing.
These are not efficient in performing operations These are efficient in performing operations
applicable to the entire datasets and hence applicable to the entire dataset and hence enables
aggregation in row‐oriented is an expensive job or aggregation over many rows and columns.
operations.
12
School of Computer Engineering
Column‐Based Database
Column-oriented databases work
on column family and based on
BigTable paper by Google. Every
column is treated separately.
Values of single column
databases are stored
contiguously. They deliver high
performance on aggregation
queries like SUM, COUNT, AVG,
MIN etc. as the data is readily
available in a column. Such
NoSQL databases are widely used
to manage data warehouses,
business intelligence, CRM,
Library card catalogs etc.
13
School of Computer Engineering
Column‐Based cont’d
14
School of Computer Engineering
Graph‐Based
A graph type database stores entities as well the relations amongst those
entities. The entity is stored as a node with the relationship as edges. An edge
gives a relationship between nodes. Every node and edge has a unique identifier.
Graph base database mostly used for social networks, logistics, spatial data.
15
School of Computer Engineering
Advantages of NoSQL
Can be used as Primary or Analytic Data Source
Big Data Capability
No Single Point of Failure
Easy Replication
No Need for Separate Caching Layer
Provides fast performance and horizontal scalability.
Can handle structured, semi-structured, and unstructured data with equal effect
NoSQL databases don't need a dedicated high-performance server
Support Key Developer Languages and Platforms
Simple to implement than using RDBMS
It can serve as the primary data source for online applications.
Handles big data which manages data velocity, variety, volume, and complexity
Excels at distributed database and multi-data center operations
Eliminates the need for a specific caching layer to store data
Offers a flexible schema design which can easily be altered without downtime or
service disruption
16
School of Computer Engineering
Disadvantages of NoSQL
No standardization rules
Limited query capabilities
RDBMS databases and tools are comparatively mature
It does not offer any traditional database capabilities, like consistency when
multiple transactions are performed simultaneously.
When the volume of data increases it is difficult to maintain unique values as
keys become difficult
Doesn't work as well with relational data
The learning curve is stiff for new developers
Open source options so not so popular for enterprises.
17
School of Computer Engineering
SQL vs. NoSQL
SQL NoSQL
Relational database Non‐relational, distributed database
Relational model Model‐less approach
Pre‐defined schema Dynamic schema for unstructured data
Table based databases Document‐based or graph‐based or wide
column store or key‐value pairs databases
Vertically scalable (by increasing system Horizontally scalable (by creating a cluster of
resources) commodity machines)
Uses SQL Uses UnQL (Unstructured Query Language)
Not preferred for large datasets Largely preferred for large datasets
Not a best fit for hierarchical data Best fit for hierarchical storage as it follows
the key‐value pair of storing data similar to
JSON
Emphasis on ACID properties Follows Brewer’s CAP theorem
18
School of Computer Engineering
SQL vs. NoSQL cont’d
SQL NoSQL
Supports complex querying and data keeping needs Does not have good support for complex querying
Can be configured for strong consistency Few support strong consistency (e.g., MongoDB),
few others can be configured for eventual
consistency (e.g., Cassandra)
Examples: Oracle, DB2, MySQL, MS SQL, Examples: MongoDB, HBase, Cassandra, Redis,
PostgreSQL, etc. Neo4j, CouchDB, Couchbase, Riak, etc.
19
School of Computer Engineering