What is NoSQL?

NoSQL encompasses a wide variety of different database technologies that were developed in response to the demands presented in building modern applications:

Developers are working with applications that create massive volumes of new, rapidly changing data types — structured, semi-structured, unstructured and polymorphic data.

Long gone is the twelve-to-eighteen month waterfall development cycle. Now small teams work in agile sprints, iterating quickly and pushing code every week or two, some even multiple times every day.

Applications that once served a finite audience are now delivered as services that must be always-on, accessible from many different devices and scaled globally to millions of users.

Organizations are now turning to scale-out architectures using open software technologies, commodity servers and cloud computing instead of large monolithic servers and storage infrastructure.

Relational databases were not designed to cope with the scale and agility challenges that face modern applications, nor were they built to take advantage of the commodity storage and processing power available today(MongoDB, https://www.mongodb.com/nosql-explained).

Taking the flights database from MySQL and migrating it MongoDB using R

Importing the Libraries

library(tidyverse)
## -- Attaching packages ------------------------------------------------------ tidyverse 1.2.1 --
## v ggplot2 3.2.1     v purrr   0.3.2
## v tibble  2.1.3     v dplyr   0.8.3
## v tidyr   0.8.3     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.4.0
## -- Conflicts --------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(RMySQL)
## Loading required package: DBI
library(mongolite)

Establishing connection between R and MySQL

password <- read_lines("password")
con <- dbConnect(MySQL(), user='root', password=password, dbname='flights', host='localhost')
SQLTables <- dbListTables(con)

Getting the datasets

tablesSQL<-list()
for(i in 1:length(SQLTables)){
  tablesSQL[[i]]<-data.frame(dbReadTable(con,SQLTables[i]))
}
names(tablesSQL)<-SQLTables

Transfering the datasets to MongoDB

for(i in 1:length(SQLTables)){
  c<-mongo(collection = SQLTables[i],db="flights")
  c$insert(tablesSQL[[i]])
}

The Data sets flights are present in MongoDB

The Benefits of NoSQL

When compared to relational databases, NoSQL databases are more scalable and provide superior performance, and their data model addresses several issues that the relational model is not designed to address:

Large volumes of rapidly changing structured, semi-structured, and unstructured data

Agile sprints, quick schema iteration, and frequent code pushes

Object-oriented programming that is easy to use and flexible

Geographically distributed scale-out architecture instead of expensive, monolithic architecture (MongoDB, https://www.mongodb.com/nosql-explained)