SlideShare a Scribd company logo
1 of 8
Download to read offline
SQL VS NOSQL: DEEP DIVE
As we have walked through earlier in the last topic, now I suppose you have built
your team and you have the SQL/NoSQL versatile guy. Then he can make value
out of this one!
Caution: This article is not intended for beginners/ Amateurs.
Warm Up:
I will start with a warm up example before we dive in this comparison,
The following figure is a simple demonstration to compare between an RDBMS table
and a simple graph structured database for friendship relations which was introduced
by Healey. So, simply on the left it is schemaless structured and on the right this shows
how it can be extended to a normal structured schema.
Also before diving deep, we can just revise the simple instructions, by a simple example of both
representations.
Schemaless simply means that two documents, (a NoSQL data structure we will
discuss) can have different fields, or common fields that store different types of data as
this example:
var cars = [
{ Model: "BMW", Color: "Red", Manufactured: 2016 },
{ Model: "Mercedes", Type: "Coupe", Color: "Black", Manufactured: “1-1-2017” }
];
The basic difference in representation between SQL and NoSQL common technologies
, is the support of JOIN in SQL, it is as simple as joining two tables like this one.
SELECT Orders.OrderID, Customers.Name, Orders.Date
FROM Orders
INNER JOIN Customers
ON Orders.CustID = Customers.CustID
One major difference between NoSQL and SQL is that NoSQL databases are more
scalable than SQL databases. MongoDB for example has built in support for replication
and sharding (horizontal partitioning of data) to support this scalability. On the other
hand,SQL databases have less scalability but they ensure very high consistency and
they support fault tolerance, built in journaling and transaction management.
Sounds simple till now, but I assume that you have refreshed your mind skillset and we
can speak more technically. Let’s take this from the point of view of the compaction, the
NoSQL recently proposed compation algorithm by Ghosh and Gupta shows that it is
very challenging to handle the continuous generation of sstables (sorted string tables) ;
this is the file of key value string paired sorted by keys. The continuous generation of
sstables at a server overtime causes the read operation to contact multiple sstables
creating a disk I/O bottleneck for reads, so reads are slower than writes in NoSQL
databases, and for that, the NoSQL systems run the compaction protocols in the
background. The compaction algorithm to merge multiple sstables into a single sstable
by the merge sorting keys is NP-hard !
So, apparently, SQL doesn’t have this complexity deep inside it has simpler
implementation, but that of course at the cost of scalability. SQL databases are of
course less scalable.
Scalability:
Now take a deep breath! We are still in the shallow surface but at least we can now see
the corals, and we have an overview of the scalability for both. To further discuss this I
will go to Cattell’s proposed classification for the different data stores.
Data store
type
Use case Example Hints/Recommendations
Key-value
Store
For simple
application with
only one kind of
object,
and you only need
to look up objects
based on one
attribute.
Facebook’s
user home page’s
live updates.
Developers familiarity of
memcached is
recommended
Move to document store if
you intend to make key
value store lookups based
on multiple attributes.
Document
Store
for multiple
different kinds of
objects
Department of
Motor Vehicles
application,
with vehicles and
drivers), where
you need to look
up
objects based on
multiple fields
(say, a driver’s
name,
license number,
owned vehicle, or
birth date)
Use it when you accept to
tolerate
an “eventually consistent”
model with limited
atomicity and isolation.
“quorum-read”mechanism is
recommended for up to date
atomically consistent data.
Extensible
Record
Store
Higher throughput
and stronger
concurrency at the
cost of slightly
more complexity
than document
store
EBay style
applications:
Partitioning data
both vertically and
horizontally for
storing customer
information on an
HBase or Hypertable is used
for this partitioning
and making it easily
extensible.
Scalable
RDBMS
The usage of
ACID semantics to
free developers
from dealing with
locks, out-of-date
data, update
collisions, and
consistency;
Applications
which
do not demand
updates or joins
that span many
Nodes
Use MySQL clusters
(VoltDB and Clustrix) as
they were benchmarked for
improved scalability.
Now it is important to know the benchmarking KPIs for this scalability assessment,
The benchmarking is pivoted on three main axes: the concurrency, Data storage and
replication. The concurrency is pinned on the mechanism of locking, mutli version
concurrency control and the ACID. The data storage is to check either it is in memory
(Ram based) or disk based. The replication is split to two types either it is synchronous
or asynchronous.
By this kind of benchmarking and testing, the conclusion was that the cluster SQL
databases have shown promising performance per node as well as the capacity of
performing at scale. And hence SQL scalable RDBMS still has some competitive
advantage over the NoSQL data stores because of the convenience of the higher-level
SQL and ACID properties but you are about to lose this advantage if you are spanning
nodes.
NoSQL Characteristics:
NoSQL databases have been distinguished over SQL databases with three main
characteristics that stick to the CAP theorem developed by computer scientist Eric
Brewer which states that “it is impossible for a distributed computer system to
simultaneously provide more than two out of three of the following guarantees:
Consistency. Availability. Partition tolerance.”
Indexing:
“I'm trying to create indexes on a table with 308 million rows. It took ~20 minutes to load the
table but 10 days to build indexes on it.” ‣ MySQL bug #9544 • “Select queries were slow until I
added an index onto the timestamp field... Adding the index really helped our reporting, BUT
now the inserts are taking forever.” ‣ This was a comment on mysqlperformanceblog.com.
The SQL databases always follow the B-Tree indexing structure and it is the well-known for
almost all the DBMS. On the other hand, the NoSQL databases use the key/value pair index
structures or the T-trees. To better have a grasp of the T-tree, the next diagram indicates the
structure of the T-Tree with pointers in each T-Node.
In some cases, like in MongoDB it uses the B-Tree indexing with Memory-mapped files
indexing pointer. More contributions were done by Otoo, Nimako and Kwofie for developing
more advanced indexing algorithms like the O2-Tree for the In-Memory Database.
In general, the column store indexes are not the same like the traditional indices, they are more
like pre-aggregated statistics. This column store indexing structure was introduced in SQL
server 2012 and it requires you to specify what fields you want to index.
However, it is a fact to say that on absolute NoSQL systems needs indexing as they are too
fragmented in structure not like the SQL databases. Nevertheless, Cassandra has also introduced
secondary indexing over the single clustering indexing. In the next diagram, Victoria Malaya,
has summarized this in correspondence between MongoDB and SQL server in the following
diagram to illustrate the difference between SQL server DB and MongoDB indexing, the SQL
server database index on the column level and MongoDB indexes on the collection level and
and supports indexing on any field or subfield of the document in the MongoDB collection,
Business state of the art (Hybrid):
The current state of the art and the business need may require a hybrid structure that includes
NoSQL alongside SQL. A nice representation for that was introduced by Moniruzzaman.
However, there is big trend for moving to NoSQL more, due to the lack of flexibility and the
rigid schemas of SQL, with the high latency alongside the low performance compared to
NoSQL in addition to the inability to scale out data with the same power.
The authors of SQLite and CouchDB have proposed UnQL2 as an attempt to create a hybrid
SQL-NoSQL query language. UnQL is based on SQL with an extension to query NoSQL data
Complex use cases of SQL vs NoSQL:
Now I will cover couple of examples to show the difference in implementation for both,
1- The SQL (relational database) vs the NoSQL (document and graph database)
The below designs are for an app designed for testing purposes and it acts as a social networking
portal, it provides the common features for social media (friends grouping, private messaging,
microblogging, rate and write comments, add tags to topics...).. Just to have the sense of how this
can be, here is a highlevel snapshot of the three proposed designs.
1- Relational database 2- Document Database 3- Graph database.
(SQL PostgreSQL) (NoSQL MongoDB) (NoSQL Neo4j)
Later there were lots of performance test cases applied, using the execution time as
benchmarking. But this is out of our scope this is only for demonstrating the idea of the
design.
2-Image processing
In NoSQL databases like MongoDB you can do image processing by using NodeJs modules like
sharp , Jimp and many more and this is the mainstream nowadays. What is may be more
interesting is using SQL in image processing; you can use something like PixQL which is an
SQL inspired command-line image processing.
You can also use pure SQL in image processing but this is more complicated and you will need
some advanced design like this one:
These diagrams represent the OLTP transactional layer and the ROLAP cube to store
information about objects.
An example query to calculate image histogram info from the cube.
SELECT
FK_OBJECTS_ID,
1 AS CHANNEL,
RED AS BRIGHTNESS, 1 AS IMG_AREA,
COUNT(*) AS VALUE
FROM
FACT_IMAGES
GROUP BY
FK_OBJECTS_ID, RED
UNION ALL
SELECT
FK_OBJECTS_ID, 2 AS CHANNEL,
GREEN AS BRIGHTNESS,
1 AS IMG_AREA,
COUNT(*) AS VALUE
FROM
FACT_IMAGES
GROUP BY
FK_OBJECTS_ID,
GREEN
UNION ALL
SELECT
FK_OBJECTS_ID,
3 AS CHANNEL,
BLUE AS BRIGHTNESS,
1 AS IMG_AREA,
COUNT(*) AS VALUE
FROM
FACT_IMAGES
GROUP BY
FK_OBJECTS_ID,
BLUE
UNION ALL
SELECT FK_
OBJECTS_ID,
4 AS CHANNEL,
ALPHA AS BRIGHTNESS,
1 AS IMG_AREA,
COUNT(*) AS VALUE
FROM FACT_IMAGES
GROUP BY
FK_OBJECTS_ID, ALPHA
CRM Application:
Another application of using both is a company which stores the CRM on both database types,
the product info and related data on a NoSQL database and the CRM data on an SQL database.
This topic opens lots of discussions as there is big debate on this data bridging, so that dividing
the same application data over SQL and NoSQL generates a gap in terms of data access.
Conclusion:
After we have just explored the corals! you should have clearly noticed that favoring
SQL over NoSQL or using both alongside each other, is dependent on your business
context and the utilization of the resources you have. Every application and every
business demand has its own feasibility study and criteria. So, there is no battle between
SQL and NoSQL, it is a harmony!

More Related Content

What's hot

NoSQL - 05March2014 Seminar
NoSQL - 05March2014 SeminarNoSQL - 05March2014 Seminar
NoSQL - 05March2014 SeminarJainul Musani
 
NOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQLNOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQLRamakant Soni
 
NoSQL Now! NoSQL Architecture Patterns
NoSQL Now! NoSQL Architecture PatternsNoSQL Now! NoSQL Architecture Patterns
NoSQL Now! NoSQL Architecture PatternsDATAVERSITY
 
NoSQL Options Compared
NoSQL Options ComparedNoSQL Options Compared
NoSQL Options ComparedSergey Bushik
 
Nosql part1 8th December
Nosql part1 8th December Nosql part1 8th December
Nosql part1 8th December Ruru Chowdhury
 
Mule database-connectors
Mule database-connectorsMule database-connectors
Mule database-connectorsPhaniu
 
SQL Server 2008 Overview
SQL Server 2008 OverviewSQL Server 2008 Overview
SQL Server 2008 OverviewDavid Chou
 
NoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenNoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenLorenzo Alberton
 
Introduction to sql server
Introduction to sql serverIntroduction to sql server
Introduction to sql serverVinay Thota
 
NoSQL Architecture Overview
NoSQL Architecture OverviewNoSQL Architecture Overview
NoSQL Architecture OverviewChristopher Foot
 
Sql vs NoSQL-Presentation
 Sql vs NoSQL-Presentation Sql vs NoSQL-Presentation
Sql vs NoSQL-PresentationShubham Tomar
 
To SQL or NoSQL, that is the question
To SQL or NoSQL, that is the questionTo SQL or NoSQL, that is the question
To SQL or NoSQL, that is the questionKrishnakumar S
 
Introduction to database with ms access.hetvii
Introduction to database with ms access.hetviiIntroduction to database with ms access.hetvii
Introduction to database with ms access.hetvii07HetviBhagat
 
DbVisualizer for NonStop SQL
DbVisualizer for NonStop SQLDbVisualizer for NonStop SQL
DbVisualizer for NonStop SQLFrans Jongma
 

What's hot (20)

NoSQL - 05March2014 Seminar
NoSQL - 05March2014 SeminarNoSQL - 05March2014 Seminar
NoSQL - 05March2014 Seminar
 
No SQL and MongoDB - Hyderabad Scalability Meetup
No SQL and MongoDB - Hyderabad Scalability MeetupNo SQL and MongoDB - Hyderabad Scalability Meetup
No SQL and MongoDB - Hyderabad Scalability Meetup
 
NOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQLNOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQL
 
NoSQL Now! NoSQL Architecture Patterns
NoSQL Now! NoSQL Architecture PatternsNoSQL Now! NoSQL Architecture Patterns
NoSQL Now! NoSQL Architecture Patterns
 
NoSQL Options Compared
NoSQL Options ComparedNoSQL Options Compared
NoSQL Options Compared
 
Nosql
NosqlNosql
Nosql
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
Nosql part1 8th December
Nosql part1 8th December Nosql part1 8th December
Nosql part1 8th December
 
Mule database-connectors
Mule database-connectorsMule database-connectors
Mule database-connectors
 
SQL Server 2008 Overview
SQL Server 2008 OverviewSQL Server 2008 Overview
SQL Server 2008 Overview
 
NoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenNoSQL Databases: Why, what and when
NoSQL Databases: Why, what and when
 
Introduction to sql server
Introduction to sql serverIntroduction to sql server
Introduction to sql server
 
Sqlmr
SqlmrSqlmr
Sqlmr
 
NoSQL Architecture Overview
NoSQL Architecture OverviewNoSQL Architecture Overview
NoSQL Architecture Overview
 
Sql vs NoSQL-Presentation
 Sql vs NoSQL-Presentation Sql vs NoSQL-Presentation
Sql vs NoSQL-Presentation
 
To SQL or NoSQL, that is the question
To SQL or NoSQL, that is the questionTo SQL or NoSQL, that is the question
To SQL or NoSQL, that is the question
 
NoSQL - what's that
NoSQL - what's thatNoSQL - what's that
NoSQL - what's that
 
Introduction to database with ms access.hetvii
Introduction to database with ms access.hetviiIntroduction to database with ms access.hetvii
Introduction to database with ms access.hetvii
 
NoSQL databases
NoSQL databasesNoSQL databases
NoSQL databases
 
DbVisualizer for NonStop SQL
DbVisualizer for NonStop SQLDbVisualizer for NonStop SQL
DbVisualizer for NonStop SQL
 

Similar to SQL vs NoSQL deep dive

Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQLbalwinders
 
Why no sql ? Why Couchbase ?
Why no sql ? Why Couchbase ?Why no sql ? Why Couchbase ?
Why no sql ? Why Couchbase ?Ahmed Rashwan
 
If NoSQL is your answer, you are probably asking the wrong question.
If NoSQL is your answer, you are probably asking the wrong question.If NoSQL is your answer, you are probably asking the wrong question.
If NoSQL is your answer, you are probably asking the wrong question.Lukas Smith
 
Big data technology unit 3
Big data technology unit 3Big data technology unit 3
Big data technology unit 3RojaT4
 
Build Application With MongoDB
Build Application With MongoDBBuild Application With MongoDB
Build Application With MongoDBEdureka!
 
Sql vs NO-SQL database differences explained
Sql vs NO-SQL database differences explainedSql vs NO-SQL database differences explained
Sql vs NO-SQL database differences explainedSatya Pal
 
Enterprise NoSQL: Silver Bullet or Poison Pill
Enterprise NoSQL: Silver Bullet or Poison PillEnterprise NoSQL: Silver Bullet or Poison Pill
Enterprise NoSQL: Silver Bullet or Poison PillBilly Newport
 
Couchbase - Introduction
Couchbase - IntroductionCouchbase - Introduction
Couchbase - IntroductionKnoldus Inc.
 
CS828 P5 Individual Project v101
CS828 P5 Individual Project v101CS828 P5 Individual Project v101
CS828 P5 Individual Project v101ThienSi Le
 
SQL or NoSQL, is this the question? - George Grammatikos
SQL or NoSQL, is this the question? - George GrammatikosSQL or NoSQL, is this the question? - George Grammatikos
SQL or NoSQL, is this the question? - George GrammatikosGeorge Grammatikos
 
MongoDB Lab Manual (1).pdf used in data science
MongoDB Lab Manual (1).pdf used in data scienceMongoDB Lab Manual (1).pdf used in data science
MongoDB Lab Manual (1).pdf used in data sciencebitragowthamkumar1
 
Presentation on NoSQL Database related RDBMS
Presentation on NoSQL Database related RDBMSPresentation on NoSQL Database related RDBMS
Presentation on NoSQL Database related RDBMSabdurrobsoyon
 
EVALUATING CASSANDRA, MONGO DB LIKE NOSQL DATASETS USING HADOOP STREAMING
EVALUATING CASSANDRA, MONGO DB LIKE NOSQL DATASETS USING HADOOP STREAMINGEVALUATING CASSANDRA, MONGO DB LIKE NOSQL DATASETS USING HADOOP STREAMING
EVALUATING CASSANDRA, MONGO DB LIKE NOSQL DATASETS USING HADOOP STREAMINGijiert bestjournal
 

Similar to SQL vs NoSQL deep dive (20)

Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
NoSQL Basics and MongDB
NoSQL Basics and  MongDBNoSQL Basics and  MongDB
NoSQL Basics and MongDB
 
Why no sql ? Why Couchbase ?
Why no sql ? Why Couchbase ?Why no sql ? Why Couchbase ?
Why no sql ? Why Couchbase ?
 
If NoSQL is your answer, you are probably asking the wrong question.
If NoSQL is your answer, you are probably asking the wrong question.If NoSQL is your answer, you are probably asking the wrong question.
If NoSQL is your answer, you are probably asking the wrong question.
 
Report 2.0.docx
Report 2.0.docxReport 2.0.docx
Report 2.0.docx
 
Big data technology unit 3
Big data technology unit 3Big data technology unit 3
Big data technology unit 3
 
Build Application With MongoDB
Build Application With MongoDBBuild Application With MongoDB
Build Application With MongoDB
 
Sql vs NO-SQL database differences explained
Sql vs NO-SQL database differences explainedSql vs NO-SQL database differences explained
Sql vs NO-SQL database differences explained
 
Enterprise NoSQL: Silver Bullet or Poison Pill
Enterprise NoSQL: Silver Bullet or Poison PillEnterprise NoSQL: Silver Bullet or Poison Pill
Enterprise NoSQL: Silver Bullet or Poison Pill
 
Erciyes university
Erciyes universityErciyes university
Erciyes university
 
NoSql Databases
NoSql DatabasesNoSql Databases
NoSql Databases
 
Couchbase - Introduction
Couchbase - IntroductionCouchbase - Introduction
Couchbase - Introduction
 
CS828 P5 Individual Project v101
CS828 P5 Individual Project v101CS828 P5 Individual Project v101
CS828 P5 Individual Project v101
 
SQL or NoSQL, is this the question? - George Grammatikos
SQL or NoSQL, is this the question? - George GrammatikosSQL or NoSQL, is this the question? - George Grammatikos
SQL or NoSQL, is this the question? - George Grammatikos
 
nosql.pptx
nosql.pptxnosql.pptx
nosql.pptx
 
MongoDB Lab Manual (1).pdf used in data science
MongoDB Lab Manual (1).pdf used in data scienceMongoDB Lab Manual (1).pdf used in data science
MongoDB Lab Manual (1).pdf used in data science
 
No sql
No sqlNo sql
No sql
 
Report 1.0.docx
Report 1.0.docxReport 1.0.docx
Report 1.0.docx
 
Presentation on NoSQL Database related RDBMS
Presentation on NoSQL Database related RDBMSPresentation on NoSQL Database related RDBMS
Presentation on NoSQL Database related RDBMS
 
EVALUATING CASSANDRA, MONGO DB LIKE NOSQL DATASETS USING HADOOP STREAMING
EVALUATING CASSANDRA, MONGO DB LIKE NOSQL DATASETS USING HADOOP STREAMINGEVALUATING CASSANDRA, MONGO DB LIKE NOSQL DATASETS USING HADOOP STREAMING
EVALUATING CASSANDRA, MONGO DB LIKE NOSQL DATASETS USING HADOOP STREAMING
 

Recently uploaded

9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home ServiceSapana Sha
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024thyngster
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改yuu sss
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsVICTOR MAESTRE RAMIREZ
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Colleen Farrelly
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Sapana Sha
 

Recently uploaded (20)

Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business Professionals
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
 

SQL vs NoSQL deep dive

  • 1. SQL VS NOSQL: DEEP DIVE As we have walked through earlier in the last topic, now I suppose you have built your team and you have the SQL/NoSQL versatile guy. Then he can make value out of this one! Caution: This article is not intended for beginners/ Amateurs. Warm Up: I will start with a warm up example before we dive in this comparison, The following figure is a simple demonstration to compare between an RDBMS table and a simple graph structured database for friendship relations which was introduced by Healey. So, simply on the left it is schemaless structured and on the right this shows how it can be extended to a normal structured schema. Also before diving deep, we can just revise the simple instructions, by a simple example of both representations. Schemaless simply means that two documents, (a NoSQL data structure we will discuss) can have different fields, or common fields that store different types of data as this example: var cars = [ { Model: "BMW", Color: "Red", Manufactured: 2016 }, { Model: "Mercedes", Type: "Coupe", Color: "Black", Manufactured: “1-1-2017” } ]; The basic difference in representation between SQL and NoSQL common technologies , is the support of JOIN in SQL, it is as simple as joining two tables like this one. SELECT Orders.OrderID, Customers.Name, Orders.Date FROM Orders INNER JOIN Customers ON Orders.CustID = Customers.CustID One major difference between NoSQL and SQL is that NoSQL databases are more scalable than SQL databases. MongoDB for example has built in support for replication and sharding (horizontal partitioning of data) to support this scalability. On the other hand,SQL databases have less scalability but they ensure very high consistency and they support fault tolerance, built in journaling and transaction management.
  • 2. Sounds simple till now, but I assume that you have refreshed your mind skillset and we can speak more technically. Let’s take this from the point of view of the compaction, the NoSQL recently proposed compation algorithm by Ghosh and Gupta shows that it is very challenging to handle the continuous generation of sstables (sorted string tables) ; this is the file of key value string paired sorted by keys. The continuous generation of sstables at a server overtime causes the read operation to contact multiple sstables creating a disk I/O bottleneck for reads, so reads are slower than writes in NoSQL databases, and for that, the NoSQL systems run the compaction protocols in the background. The compaction algorithm to merge multiple sstables into a single sstable by the merge sorting keys is NP-hard ! So, apparently, SQL doesn’t have this complexity deep inside it has simpler implementation, but that of course at the cost of scalability. SQL databases are of course less scalable. Scalability: Now take a deep breath! We are still in the shallow surface but at least we can now see the corals, and we have an overview of the scalability for both. To further discuss this I will go to Cattell’s proposed classification for the different data stores. Data store type Use case Example Hints/Recommendations Key-value Store For simple application with only one kind of object, and you only need to look up objects based on one attribute. Facebook’s user home page’s live updates. Developers familiarity of memcached is recommended Move to document store if you intend to make key value store lookups based on multiple attributes. Document Store for multiple different kinds of objects Department of Motor Vehicles application, with vehicles and drivers), where you need to look up objects based on multiple fields (say, a driver’s name, license number, owned vehicle, or birth date) Use it when you accept to tolerate an “eventually consistent” model with limited atomicity and isolation. “quorum-read”mechanism is recommended for up to date atomically consistent data.
  • 3. Extensible Record Store Higher throughput and stronger concurrency at the cost of slightly more complexity than document store EBay style applications: Partitioning data both vertically and horizontally for storing customer information on an HBase or Hypertable is used for this partitioning and making it easily extensible. Scalable RDBMS The usage of ACID semantics to free developers from dealing with locks, out-of-date data, update collisions, and consistency; Applications which do not demand updates or joins that span many Nodes Use MySQL clusters (VoltDB and Clustrix) as they were benchmarked for improved scalability. Now it is important to know the benchmarking KPIs for this scalability assessment, The benchmarking is pivoted on three main axes: the concurrency, Data storage and replication. The concurrency is pinned on the mechanism of locking, mutli version concurrency control and the ACID. The data storage is to check either it is in memory (Ram based) or disk based. The replication is split to two types either it is synchronous or asynchronous. By this kind of benchmarking and testing, the conclusion was that the cluster SQL databases have shown promising performance per node as well as the capacity of performing at scale. And hence SQL scalable RDBMS still has some competitive advantage over the NoSQL data stores because of the convenience of the higher-level SQL and ACID properties but you are about to lose this advantage if you are spanning nodes. NoSQL Characteristics: NoSQL databases have been distinguished over SQL databases with three main characteristics that stick to the CAP theorem developed by computer scientist Eric Brewer which states that “it is impossible for a distributed computer system to simultaneously provide more than two out of three of the following guarantees: Consistency. Availability. Partition tolerance.”
  • 4. Indexing: “I'm trying to create indexes on a table with 308 million rows. It took ~20 minutes to load the table but 10 days to build indexes on it.” ‣ MySQL bug #9544 • “Select queries were slow until I added an index onto the timestamp field... Adding the index really helped our reporting, BUT now the inserts are taking forever.” ‣ This was a comment on mysqlperformanceblog.com. The SQL databases always follow the B-Tree indexing structure and it is the well-known for almost all the DBMS. On the other hand, the NoSQL databases use the key/value pair index structures or the T-trees. To better have a grasp of the T-tree, the next diagram indicates the structure of the T-Tree with pointers in each T-Node.
  • 5. In some cases, like in MongoDB it uses the B-Tree indexing with Memory-mapped files indexing pointer. More contributions were done by Otoo, Nimako and Kwofie for developing more advanced indexing algorithms like the O2-Tree for the In-Memory Database. In general, the column store indexes are not the same like the traditional indices, they are more like pre-aggregated statistics. This column store indexing structure was introduced in SQL server 2012 and it requires you to specify what fields you want to index. However, it is a fact to say that on absolute NoSQL systems needs indexing as they are too fragmented in structure not like the SQL databases. Nevertheless, Cassandra has also introduced secondary indexing over the single clustering indexing. In the next diagram, Victoria Malaya, has summarized this in correspondence between MongoDB and SQL server in the following diagram to illustrate the difference between SQL server DB and MongoDB indexing, the SQL server database index on the column level and MongoDB indexes on the collection level and
  • 6. and supports indexing on any field or subfield of the document in the MongoDB collection, Business state of the art (Hybrid): The current state of the art and the business need may require a hybrid structure that includes NoSQL alongside SQL. A nice representation for that was introduced by Moniruzzaman. However, there is big trend for moving to NoSQL more, due to the lack of flexibility and the rigid schemas of SQL, with the high latency alongside the low performance compared to NoSQL in addition to the inability to scale out data with the same power. The authors of SQLite and CouchDB have proposed UnQL2 as an attempt to create a hybrid SQL-NoSQL query language. UnQL is based on SQL with an extension to query NoSQL data
  • 7. Complex use cases of SQL vs NoSQL: Now I will cover couple of examples to show the difference in implementation for both, 1- The SQL (relational database) vs the NoSQL (document and graph database) The below designs are for an app designed for testing purposes and it acts as a social networking portal, it provides the common features for social media (friends grouping, private messaging, microblogging, rate and write comments, add tags to topics...).. Just to have the sense of how this can be, here is a highlevel snapshot of the three proposed designs. 1- Relational database 2- Document Database 3- Graph database. (SQL PostgreSQL) (NoSQL MongoDB) (NoSQL Neo4j) Later there were lots of performance test cases applied, using the execution time as benchmarking. But this is out of our scope this is only for demonstrating the idea of the design. 2-Image processing In NoSQL databases like MongoDB you can do image processing by using NodeJs modules like sharp , Jimp and many more and this is the mainstream nowadays. What is may be more interesting is using SQL in image processing; you can use something like PixQL which is an SQL inspired command-line image processing. You can also use pure SQL in image processing but this is more complicated and you will need some advanced design like this one: These diagrams represent the OLTP transactional layer and the ROLAP cube to store information about objects. An example query to calculate image histogram info from the cube. SELECT FK_OBJECTS_ID, 1 AS CHANNEL,
  • 8. RED AS BRIGHTNESS, 1 AS IMG_AREA, COUNT(*) AS VALUE FROM FACT_IMAGES GROUP BY FK_OBJECTS_ID, RED UNION ALL SELECT FK_OBJECTS_ID, 2 AS CHANNEL, GREEN AS BRIGHTNESS, 1 AS IMG_AREA, COUNT(*) AS VALUE FROM FACT_IMAGES GROUP BY FK_OBJECTS_ID, GREEN UNION ALL SELECT FK_OBJECTS_ID, 3 AS CHANNEL, BLUE AS BRIGHTNESS, 1 AS IMG_AREA, COUNT(*) AS VALUE FROM FACT_IMAGES GROUP BY FK_OBJECTS_ID, BLUE UNION ALL SELECT FK_ OBJECTS_ID, 4 AS CHANNEL, ALPHA AS BRIGHTNESS, 1 AS IMG_AREA, COUNT(*) AS VALUE FROM FACT_IMAGES GROUP BY FK_OBJECTS_ID, ALPHA CRM Application: Another application of using both is a company which stores the CRM on both database types, the product info and related data on a NoSQL database and the CRM data on an SQL database. This topic opens lots of discussions as there is big debate on this data bridging, so that dividing the same application data over SQL and NoSQL generates a gap in terms of data access. Conclusion: After we have just explored the corals! you should have clearly noticed that favoring SQL over NoSQL or using both alongside each other, is dependent on your business context and the utilization of the resources you have. Every application and every business demand has its own feasibility study and criteria. So, there is no battle between SQL and NoSQL, it is a harmony!