#The library for the MYSQL connection
library(DBI)

For this assigment I used Google cloud MySQL database DB link

DataBase ERR link

con <- dbConnect(RMySQL::MySQL(), 
                 dbname = "movie", 
                 host = "35.184.91.108", 
                 port = 3306,
                 user = "root",
                 password = "root")

data <- dbGetQuery(con, "select u.name,r.scale_rating,m.movie_name from user u
left join rating r
on u.iduser = r.iduser
left join movie_rating mr
on r.idrating = mr.idrating
left join movie m
on mr.idmovie = m.idmovie;")

#review of the data
head(data)
##     name scale_rating movie_name
## 1   jose            3 Spider-Man
## 2   mike            5    Titanic
## 3   mary            4    Titanic
## 4   mike            5     Batman
## 5   jose            3   Que leon
## 6 justin            2      x-men
#summarry

summary(data)
##      name            scale_rating    movie_name       
##  Length:11          Min.   :2.000   Length:11         
##  Class :character   1st Qu.:3.000   Class :character  
##  Mode  :character   Median :4.000   Mode  :character  
##                     Mean   :3.727                     
##                     3rd Qu.:4.500                     
##                     Max.   :5.000
#grouping the data by movie and the sum of the rating points and put into the graph
barplot(tapply(data$scale_rating, data$movie_name, FUN=sum), ylim = c(0,12), main = "Rating Movies", col = "blue")

observing the graph, we see that movie “batman” and “Que leon”" got the highest rating