Answer :
Final answer:
The assignment requires writing SQL queries for a movie database. The queries should be written in Postgres v13 and should work on any instance of the given schema. The queries should consider the constraints, keys, and null values. The results should be ordered as specified in the questions. The queries involve finding movies with matching genres and directors, identifying directors who have cast specific actors, reporting potential conflicts of interest, determining the genre with the highest probability for each director, and calculating the active period of directors.
Explanation:
Queries:
- Find all movies where the set of genres associated with the movie is exactly the same as the set of genres associated with all of its directors. A movie with no genres whose directors (if any) have no genres would satisfy this condition. Return the movie id and title, ordered by movie id then title.
- Return the directors who have cast at least 10 different actors but have never cast an actor who identifies as female (gender = 'F'). Each director should be returned only once with their id, lname, fname (and order the result by lname, fname).
- If a director hires an actor with the same last name but different first name, this is a potential case of conflict of interest. For each director, report the number of different actors the director has hired on any movie that director directs with the the same last name but different first name. Include directors who are not guilty of any conflict with a count of zero. For each director, return one tuple with the director's id along with last and first names of the director and the number of such (potentially related) actors. If an actor is hired for multiple movies or roles, just count that actor once. Order the output by director id, lname (of director), fname (of director).
- For each director, return the genre that has the highest probability (prob). Directors without genres should be returned with null as the genre and null prob. Treat null probabilities as zero. So a null probability is returned only if there are no genre with a non-zero probability. Return the result ordered by lname, fname, genre of the director. If there are ties (e.g., Ava has genre Drama with prob 50 and genre Suspense with prob 50 and no other genres) then a director may be returned more than once.
- The era of a director is the years from their first movie to their last. For every director return the id, lname and the length (last - first +1) of his/her/their active period (which is 0 if the director has never directed a movie). If a director directors any movie with an unknown (null) year, the active period is also unknown (null). Order result by the era length, lname, id.
Learn more about writing sql queries for a movie database here:
https://brainly.com/question/30367131
#SPJ14