Question

In: Computer Science

I am having trouble writing these queries in MYSQL. Using the schema listed below, please write...

I am having trouble writing these queries in MYSQL. Using the schema listed below, please write the following queries in MYSQL:

1) Find the Content and the Reviewer Name for each comment, about “ACADEMY DINOSAUR” only if the same reviewer has commented about “ACE GOLDFINGER” too.

2) Retrieve the title of all the Movies in Japanese without any comment, ordered alphabetically.

3) Find all the movie titles where an actor called “TOM” or an actor called “BEN" acted, where there was another actor called “MARY” acting too.

Schema:

Consider a movie relational database schema description provided below which is used to manage a movie database, where:

A movie can have 0 or more actors

A movie can have 1 or more categories

A movie has 1 and only one language

Rating is one of these values: 'G','PG','PG-13','R','NC-17'

People can comment about the movies on a webpage, and the comments are stored in the comments table. The reviewer_name is introduced by the person on each comment, so we don't have a table with “reviewers”. A reviewer can create any number of comments about a movie. The comments will have a score about the movie with values from 0 to 100.

Note, the last update fields are going to be stored as a “timestamp”.

IMPORTANT: 2 entries in the same relation can have the same lastupdate, so, for example, 2 movies can have the same lastupdate value.

The relations are:

ACTOR (actor_id, first_name, last_name, last_update)

LANGUAGE (language_id, name, last_update)

CATEGORY (category_id, name, last_update)

FILM (film_id, title, description, release_year, language_id, length, rating, last_update)

FILM_ACTOR(actor_id, film_id, last_update)

FILM_CATEGORY (film_id, category_id, last_update)

COMMENTS (review_id, film_id, reviewer_name, comment, score, last_update)

Solutions

Expert Solution

Table Create

CREATE TABLE ACTOR (actor_id INT PRIMARY KEY, first_name VARCHAR(20), last_name VARCHAR(20), last_update DATE);

CREATE TABLE LANGUAGE (language_id INT PRIMARY KEY, name VARCHAR(20), last_update DATE);
CREATE TABLE CATEGORY (category_id INT PRIMARY KEY, name VARCHAR(20), last_update DATE);
CREATE TABLE FILM (film_id INT PRIMARY KEY, title VARCHAR(20), description VARCHAR(20), release_year INT, language_id INT, length INT, rating INT, last_update DATE);
CREATE TABLE FILM_ACTOR(actor_id INT, film_id INT, last_update DATE);
CREATE TABLE FILM_CATEGORY (film_id INT, category_id INT, last_update DATE);
CREATE TABLE COMMENTS (review_id INT PRIMARY KEY, film_id INT, reviewer_name VARCHAR(20), comment VARCHAR(20), score INT, last_update DATE);


insert into LANGUAGE values(1,'Japanese','11-01-2018');
insert into LANGUAGE values(2,'English','11-01-2018');
Select * from LANGUAGE;

insert into FILM values(101,'ACADEMY DINOSAUR','none',2011,1,100,10,'01-01-2018');
insert into FILM values(102,'ACE GOLDFINGER','none',2015,2,101,5,'11-01-2018');
insert into FILM values(103,'ACE','none',2013,2,101,5,'11-01-2018');
insert into FILM values(104,'Pirates Of Curebian','none',2013,1,101,5,'11-01-2018');
Select * from FILM;

insert into COMMENTS values(201,101,'viral','good',1,'11-01-2018');
insert into COMMENTS values(202,102,'viral','Not Bad',5,'11-01-2018');
insert into COMMENTS values(203,102,'poonam','Not Bad',8,'11-01-2018');
Select * from COMMENTS;

insert into ACTOR values(301,'Tom','V','11-01-2018');
insert into ACTOR values(302,'Ben','V','11-01-2018');
insert into ACTOR values(303,'Mary','V','11-01-2018');
Select * From ACTOR;


insert into FILM_ACTOR values(301,101,'11-01-2018');
insert into FILM_ACTOR values(302,102,'11-01-2018');
insert into FILM_ACTOR values(301,103,'11-01-2018');
insert into FILM_ACTOR values(303,103,'11-01-2018');
Select * From FILM_ACTOR;


Query:
/*this is called nested query which will fetch data which is review for both acadamey Dinosur and ACE GOLDFINGER*/
Select reviewer_name from COMMENTS where film_id=(Select film_id from FILM WHERE title='ACADEMY DINOSAUR') and reviewer_name in((Select reviewer_name from COMMENTS where film_id=(Select film_id from FILM WHERE title='ACE GOLDFINGER')));

Query:
/*Here it which is japanes language film and not review*/
Select title from film where language_id=(Select language_id from LANGUAGE where name='Japanese') and film_id not in(Select film_id from comments) order by title;

Query:
/*this is example of union where we return title in both query and from both we */
SELECT title from film inner join FILM_ACTOR on film.film_id=FILM_ACTOR.film_id inner join ACTOR on actor.actor_id=FILM_ACTOR.actor_id where actor.actor_id in(Select actor_id from actor where first_name='TOM' or first_name='Ben') and title in (SELECT title from film inner join FILM_ACTOR on film.film_id=FILM_ACTOR.film_id inner join ACTOR on actor.actor_id=FILM_ACTOR.actor_id where actor.actor_id in(Select actor_id from actor where first_name='Mary'));

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........


Related Solutions

I am having a hard time writing these SQL queries. Please specify the following queries in...
I am having a hard time writing these SQL queries. Please specify the following queries in SQL on the database schema shown in the figure below. STUDENT Name StudentNumber Class Major Smith 17 1 CS Brown 8 2 CS Kathy 15 1 EE COURSE CourseName CourseNumber CreditHours Department Intro to Computer Science CSE110 4 CS Data Structures CSE205 4 CS Discrete Mathematics MAT240 3 MATH Databases CSE380 3 CS Analog Circuits EE260 3 EE SECTION SectionIdentifier CourseNumber Semester Year Instructor...
I am having trouble fixing my build errors. The compiler I am using is Visual Studio.Thanks....
I am having trouble fixing my build errors. The compiler I am using is Visual Studio.Thanks. #include <iostream> #include <string> #include <cstdlib> using namespace std; /* * structure to store employee details * employee details are stored as linked list */ struct Employee { private:    string full_name; //full name    double net_income; //income public:    struct Employee *next; //pointing to the next employee details in the list                        /*                   ...
I am having a trouble with a python program. I am to create a program that...
I am having a trouble with a python program. I am to create a program that calculates the estimated hours and mintutes. Here is my code. #!/usr/bin/env python3 #Arrival Date/Time Estimator # # from datetime import datetime import locale mph = 0 miles = 0 def get_departure_time():     while True:         date_str = input("Estimated time of departure (HH:MM AM/PM): ")         try:             depart_time = datetime.strptime(date_str, "%H:%M %p")         except ValueError:             print("Invalid date format. Try again.")             continue        ...
Using dev c++ I'm having trouble with classes. I think the part that I am not...
Using dev c++ I'm having trouble with classes. I think the part that I am not understanding is sending data between files and also using bool data. I've been working on this program for a long time with many errors but now I've thrown in my hat to ask for outside help. Here is the homework that has given me so many issues: The [REDACTED] Phone Store needs a program to compute phone charges for some phones sold in the...
using mysql and the schema is provided below. thanks In this lab, you will be manipulating...
using mysql and the schema is provided below. thanks In this lab, you will be manipulating the database to add, delete and modify the values in the database. Please use a "select * from..." after each query to show the effects of your data manipulation query. 1. The title 'Time Flies' now has a new track, the 11th track 'Spring', which is 150 seconds long and has only a MP3 file. Insert the new track into Tracks table (Don’t hand-code...
I was able to calculate (a) but I am having trouble with the calculations of (b)....
I was able to calculate (a) but I am having trouble with the calculations of (b). Thanks! The following are New York closing rates for A$/US$ and $/£:                                     A$/$ = 1.5150;               $/£ = $1.2950             (a) Calculate the cross rate for £ in terms of A$ (A$/£).             (b) If £ is trading at A$1.95/£ in London (cross market) on the same day, is there an arbitrage opportunity?  If so, show how arbitrageurs with £ could profit from this opportunity and calculate the arbitrage...
I am having trouble with the entry to adjust accumulated depreciation, can you please explain.
I am having trouble with the entry to adjust accumulated depreciation, can you please explain.
TCP client and server using C programming I am having trouble on how to read in...
TCP client and server using C programming I am having trouble on how to read in the IP adress and port number from the terminal Example: Enter IP address: 127.0.0.1 Enter Port Number: 8000 in both client and server code. How do can I make I can assign the Ip address and port number using the example above. the error I get is that the client couldn't connect with the server whenever i get the port number from the user...
Write the following queries using the schema below Class (Number, Department, Term, Title) Student (Username, FirstName,...
Write the following queries using the schema below Class (Number, Department, Term, Title) Student (Username, FirstName, LastName, Year) Takes (Username, Department, Number, Term, Grade) [clarification] In Student, Year is an integer. A student can be a 2nd year student. In that case, Year value would be 2. For the Takes relation: ·         Grade is NA for current semester students ·         Username is foreign key to Student ·         (Department, Number, Term) is foreign key to Class a)       Write an SQL query that returns the Term...
I am working through this solution in rstudio and am having trouble fitting this table into...
I am working through this solution in rstudio and am having trouble fitting this table into a linear regression analysis. an answer with corrosponding r code used would be greatly appreciated A study was conducted to determine whether the final grade of a student in an introductory psychology course is linearly related to his or her performance on the verbal ability test administered before college entrance. The verbal scores and final grades for all 1010 students in the class are...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT