Question: a) [1 pt] Import data (SQL code is provided. Test prog3_createTable.sql on your server): Each of you will work in your own database with the
a) [1 pt] Import data (SQL code is provided. Test prog3_createTable.sql on your server): Each of you will work in your own database with the name cs4402xx; Import the movie data movie-name_score.txt into a new table called movies with the schema: movies(movie_id integer, name varchar(1000), score integer) Import the movie cast data at movie-cast.txt into a new table called cast with the schema: cast(movie_id integer, cast_id integer, cast_name varchar(1000)). b) [4 pt] Add a new record to movies with id=12345, name=strangemovie,score=0) c) [5 pt] Change the name to badmovie for movie id=12345 in table movies. d) [5 pt] Remove the record for movie id=12345 from table movies. e) [5 pt] Find the movies whose title contains Warrior. Output format: movie_id, name. f) [5 pt] Finding laid back actors: List cast members (alphabetically by cast_name) with exactly 4 movie appearances. Format of each output row: cast_id, cast_name. g) [5 pt] Find the movies with score >80 and has no cast members with name David. Output format: movie_id, score. h) [5 pt] For each cast member, find the number of movies he or she played in, and the average movie scores. Filter out movies with score < 0. List those cast members in alphabetical order. Format of each output row: cast_id, cast_name, num_movies, average_score. i) [5 pt] Find the names of movies with scores higher than that of some movies containing Chronicles. (Hint: consider using set comparison in subquery) j) [10 pt] Finding good collaborators: Create a view (virtual table) called good collaboration that lists pairs of stars who appeared in movies. Each row in the table describes one pair of stars who have appeared in at least 4 movies together AND each of the movie has score >= 75. The view should have the format: collaboration (cast_member_id1, cast_member_id2, num_movies, avg_movie_score). Exclude self pairs: (cast_member_id1 == cast_member_id2). Keep symmetrical or mirror pairs. For example, keep both (A, B) and (B, A). Hint: Self-Joins will likely be a necessary. After creating a view, list (cast_member_id1, cast_member_id2, num_movies, avg_movie_score) sorted by average movie scores from the view.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
