For this assignment, you should take information from a relational database and migrate it to a NoSQL database of your own choosing. For the relational database, you might use the flights database, the tb database, the “data skills” database your team created for Project 3, or another database of your own choosing or creation. For the NoSQL database, you may use MongoDB (which we introduced in week 7), Neo4j, or another NoSQL database of your choosing. Your migration process needs to be reproducible. R code is encouraged, but not required. You should also briefly describe the advantages and disadvantages of storing the data in a relational database vs. your NoSQL database.

#clean the environment
rm(list=ls())
#loading the needed libraries

library(DBI)
library(RMySQL)
library(mongolite)
#connect to the MySql database and list all the tables 
con <- dbConnect(RMySQL::MySQL(),dbname='company',host='courses.csrrinzqubik.us-east-1.rds.amazonaws.com', port=3306,user='student',password='datacamp')
dbListTables(con)
## [1] "employees" "products"  "sales"
#query the the sales database and load the data into a dataframe 
query <- 'select * from sales;'

company.db <- dbGetQuery(conn=con, statement=query)


head(company.db)
##   id employee_id product_id       date price
## 1  1           4          5 2015-09-05    99
## 2  2           7          2 2015-09-14    75
## 3  3           6          9 2015-09-18   152
## 4  4           9          2 2015-09-21    66
## 5  5           9          5 2015-09-22    70
## 6  6           1          5 2015-09-22    41

Unfortunately I wasn’t able to connect to MongoDb.

# create connection, database and collection
#my_collection = mongo(collection = "sales", db = "company") 
#my_collection$insert(sales)

#mongo.collection$insert(company.db)