Question: create table moviesList ( movie_id integer, name varchar(1000), score integer ); create table castList ( movie_id integer, cast_id integer, cast_name varchar(1000) ); Using the tables
create table moviesList ( movie_id integer, name varchar(1000), score integer );
create table castList ( movie_id integer, cast_id integer, cast_name varchar(1000) );
Using the tables created above, create a view called pairs that lists pairs of actors who are in the same movies together. Each row in the table must be one pair of actors who appear in at least 2 movies together AND each of the movies has a score >= 80. The output should be (cast_id1, cast_id2, num_movies, avg_movie_score) and it should be sorted by avg_movie_scores. Self-Joins will be necessary to complete this problem. Exclude self pairs (i.e. cast_id1 == cast_id2), but keep symmetrical/mirror pairs (i.e. (A, B) and (B, A)).
Here are sample inserts to use. insert into moviesList values(111, "Frozen", 90); insert into moviesList values(222, "Cars", 10); insert into moviesList values(333, "Finding Nemo", 100); insert into moviesList values(444, "Toy Story", 20); insert into castList values(111, 1, "David"); insert into castList values(111, 2, "Sarah"); insert into castList values(111, 3, "Hunter"); insert into castList values(222, 4, "Jim"); insert into castList values(222, 5, "Brennan"); insert into castList values(222, 3, "Hunter"); insert into castList values(222, 2, "Sarah"); insert into castList values(333, 5, "David"); insert into castList values(333, 6, "Pat"); insert into castList values(333, 2, "Sarah"); insert into castList values(444, 7, "Kim"); insert into castList values(444, 8, "Jim"); insert into castList values(444, 3, "Hunter");
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
