Write an SQL query for the following two questions: Consider a database with the
ID: 3667161 • Letter: W
Question
Write an SQL query for the following two questions:
Consider a database with the following schema: MovieCode TheaterCode movietime MovieCode Title Rating Length TheaterCode DistrictCode Name Address Phone Name Movies table stores the movies played in theaters throughout the city; Districts stores the city districts where the movie theaters are; Theaters stores movie theaters movies2theaters stores the movies and the corresponding theaters that play that movie; theaters2districts lists the theaters and their districts; note that some theaters belong to several districts. Tables like movies2theaters and theaters2districts are sometimes called "junction" tables. They store foreign keys from main tables and connect them in this way. Junction tables are not usually meant to store any additional data/objects.Explanation / Answer
1.
SELECT t.name,t.phone FROM theater t, movie m, movies2theaters mt, district d, theaters2district td WHERE d.name = "downtown" AND m.rating = "PG-13" AND m.length = (SELECT max(length) FROM movie WHERE rating = "PG-13" ) AND mt.moviecode = m.moviecode AND t.theatercode = mt.theatercode AND d.districtcode = td.districtcode AND t.theatercode = td.theatercode ORDER BY t.name;
2.
SELECT t.name FROM theater t, movie m, movies2theaters mt WHERE m.title = "Chicken Run" AND mt.moviecode = m.moviecode AND t.theatercode = mt.theatercode ;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.