Question
Instructions: This homework is based on the following movie database. The table definitions are listed below. You dont need to run these code. CREATE TABLE
Instructions: This homework is based on the following movie database. The table definitions are listed below. You dont need to run these code. CREATE TABLE actor( id INTEGER NOT NULL, name VARCHAR2(100), CONSTRAINT actor_PK PRIMARY KEY (id)); CREATE TABLE movie( id INTEGER NOT NULL, title VARCHAR2(100), yr NUMBER(4,0), score NUMBER, votes INTEGER, director VARCHAR2(100), CONSTRAINT movie_PK PRIMARY KEY (id)); CREATE TABLE casting( movie_id INTEGER NOT NULL, actor_id INTEGER NOT NULL, ord INTEGER, CONSTRAINT casting_PK PRIMARY KEY (movie_id, actor_id), CONSTRAINT casting_FK1 FOREIGN KEY (movie_id) REFERENCES movie(id), CONSTRAINT casting_FK2 FOREIGN KEY (actor_id) REFERENCES actor(id)); In the casting table, ord refers to the order of an actor in a movies cast list (ord = 1 refers to the leading actor). In this database, actors include both male and female. In this homework, we simply use Actors to represent all the actors and actresses in the data. In the movie table, yr is the year in which the movie is released. score is the average rating of a movie between 0 and 10 (inclusive). votes is the total number of people who rated the movie. 2 The database is created in the instructors account (MS3200125). You should run the following commands in your SQL Developer to create a virtual copy of the database in your own account. Then, you may directly use the three tables from your account. create synonym movie for MS3200125.movie; create synonym actor for MS3200125.actor; create synonym casting for MS3200125.casting; To test if the above comments are correctly executed, you may run a simple query such as: SELECT COUNT(*) FROM movie; The correct output should be 9992. Q1. (10 pts) Show the title and the leading actors name of the movie with id = 2579806. Q2. (10 pts) List all the movies played by 'Stewart, Kristen'. Show the id, title and year of these movies. Sort the results in chronological order (early movies first). Q3. (10 pts) Calculate the average score of all the movies played by 'DiCaprio, Leonardo'. Q4. (10 pts) List all the movies directed by the director of the movie 'Iron Man'. Show the title and year of these movies. Sort the results in chronological order (early movies first). Q5. (10 pts) How many movies with actor Schwarzenegger, Arnold were directed by 'Cameron, James'? You just need to show one number. Q6. (10 pts) Which movie has the highest score? Show the title as well as the score of this movie. Do NOT use the Order By clause. If multiple movies share the same highest score, show all of these movies. Q7. (10 pts) Find the movies with both 'Cooper, Bradley' and 'Lawrence, Jennifer' at the same time. Show the titles of these movies. Q8. (10 pts) Find the directors who have collaborated with more than 200 different actors. Show the names of these directors and the number of different actors they each have collaborated with. Sort the results based on the number of actors in descending order. Q9. (10 pts) Find the directors who have never directed any movie that were rated below 9.0 (score). List the names of these directors. Q10. (10 pts) Find all the movies whose titles begin with 'Star Trek'. Show the title, year, score, and the name of the leading actor of these movies. Sort the results by year in descending order. Remove any duplicate rows in the result.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started