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.
I created a MySQL database from Project 3’s Characteristics, Salary, and Skills tables. These tables contain occupational data for Mathematical and Computer Science career fields.
Below, I use RMySQL connect to the MySQL database and create three dataframes for the Project 3 tables, “salary”, “skills”, and “characteristics.” I then use a loop to rewrite this tables as csvs to import to mongodb.
try(setwd("../week12"))
con <- dbConnect(MySQL(),
user=user, password=localpassword,
dbname='wk13',
host='localhost')
salary <- dbReadTable(con, "salary")
skills <- dbReadTable(con, "skills")
characteristics <- dbReadTable(con, "characteristics")
tbl <- dbListTables(con)
tbl## [1] "characteristics" "salary" "skills"
i<-1
for (i in 1:length(tbl)){
j <- dbReadTable(con, tbl[i])
write.csv(j, file = paste(tbl[i],".csv"), row.names = FALSE)
}
dbDisconnect(con)## [1] TRUE
Despite reviewing the instructions, I was unable to make a command line connection to my mongodb rootuser………
library(mongolite)