```

Choose six recent popular movies. Ask at least five people that you know (friends, family, classmates, imaginary friends) to rate each of these movie that they have seen on a scale of 1 to 5. Take the results (observations) and store them in a SQL database. Load the information into an R dataframe. Your deliverables should include your SQL scripts and your R Markdown code, posted to GitHub.

Load the necessary libraries

library(dbplyr)
library(RMySQL)
## Loading required package: DBI
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:dbplyr':
## 
##     ident, sql
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(knitr)

Connect RStudio with MySQL database to load the file

mydb = dbConnect(MySQL(),
                 user='root', password='password',
                 dbname='607_hw2', host='localhost')

Retrieve the joined tables together through Join Query

mysql <- "select movies.movieid, movies.movieyear, respondent1.ratingid, respondent1.John, respondent1.James, 
respondent1.Peter, respondent1.Carol, respondent1.Steve from movies 

left join respondent1

on movies.movieid = respondent1.movieid;"

moviename <- dbGetQuery(mydb, mysql)
moviename
##   movieid movieyear ratingid John James Peter Carol Steve
## 1       1      2019        1    4     5     4     4     5
## 2       2      2019        2    5     5     4     3     4
## 3       3      2019        3    3     4     4     4     5
## 4       4      2019        4    4     4     3     4     5
## 5       5      2019        5    4     4     5     3     3
## 6       6      2019        6    3     3     4     4     4