Question

Suppose a database has the following three relations. Movie (mid: integer, title: string, director: string, releaseDate:...

Suppose a database has the following three relations.
Movie (mid: integer, title: string, director: string, releaseDate: date)
PlaysAt (theaterID: integer, movieId: integer, showDate: date)
Theater (tID: integer, name: string, phone: string, screencount: integer)
"movieID" in PlaysAt is a foreign key referencing "mid" in Movie. "theaterID" in PLaysAt is a foreign key referencing "tID" in Theater.

Write the following queries in both relational algebra and SQL.

  1. Find the titles of movies playing on 2 / 26 / 2019 and the IDs of the theaters they are playing at. (You may assume that a simple "=" works on the date data type.)
  2. Find the names of theaters that are playing a movie titled "Pride and Prejudice" and a movie titled "Sense and Sensibility."
  3. Find the phone numbers of theaters where the movie titled "The Green Book" is playing on 3 / 2 / 2019.

Write the following queries in SQL only.

  1. Find the titles and movie IDs of movies whose titles start with "Ha" and end with "en".
  2. For each movieID, find the number of different theaters that are playing the movie on 2 / 26 / 2019. (List both movieIDs and counts of theaters in output.)
  3. List all movieIDs and movie titles. If the movie is playing in a movie theater, also list the theater's ID and the show date.
  4. For each theaterID, find the number of different movies that are playing at that theater on 11 / 9 / 2018. The user is only interested in information about theaters that are playing more than three movies on 11 / 9. (List both theater IDs and counts of movies in output.)
0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Suppose a database has the following three relations. Movie (mid: integer, title: string, director: string, releaseDate:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the following query in SQL Suppose a database has the following three relations Movie (mid:...

    Write the following query in SQL Suppose a database has the following three relations Movie (mid: integer, title: string, director: string, relcaseDate: date) PlaysAt (theaterID: integer. movieId:integer. showDate: date) Theater (tID: integer, name: string, phone: string, screencount: integer) movielD" in PlaysAt is a foreign key referencing "mid" in Movie. "theaterlD" in PLaysAt is a foreign key referencing "tID" in Theater.

  • Suppose a database has the following three relations. Museum (mid: integer, name: string, address: string, website:...

    Suppose a database has the following three relations. Museum (mid: integer, name: string, address: string, website: string) Displays (museumID: integer, artID: integer, startDate: date) ArtItem (aid: integer, title: string, weightPnd: integer, type: string) Artist (pid: integer, firstname: string, lastname: string, birthdate: date, deathdate: date) Creates (artistID: integer, artID: integer, year: integer) (The "bit" data type stores 0 or 1. False or true. Booleans.) "museumID" in Displays is a foreign key referencing "mid" in Museum. "artistID" in Creates is a foreign...

  • Consider the following relations: Patient (pid: integer, lname: string, fname: string, primary_did: integer, age: integer) Doctor...

    Consider the following relations: Patient (pid: integer, lname: string, fname: string, primary_did: integer, age: integer) Doctor (did: integer, lname: string, fname: string, deptid: integer, age: integer, salary: integer) Nurse (nid: integer, lname: string, fname: string, deptid: integer, rank: string, age: integer) Department (deptid: integer, name: string, budget: integer) Menu (menuid: integer, pid: integer, caloriecount: integer, saltlevel: integer, vegetarian: bit, diabetic: bit, nauseaSafe: bit, notes: string) Vaccination (vaccinationid: integer, pid: integer, vaccinationname: string, dategiven: date, dateexpires: date) Prescription (presid: integer, pid:integer,...

  • Consider the database consisting of the following relations: Flights(Fl#: integer, From: string, To: string, Distance: integer,...

    Consider the database consisting of the following relations: Flights(Fl#: integer, From: string, To: string, Distance: integer, departs: Time, Arrives: time) Flight Instance(Fl#: integer, Day: date, Aid: Integer) Aircraft(Aid: integer, Make: string, Model: string, CrusingRange: string) Certified(Eid: integer, Make: string, Model: string) Employee(Eid: integer, Ename: string, Salary: integer) Fight Attendant(Fl#: integer, Day: date, Eid:integer, Role: string) The Flight table contains general information about the flights whereas the Flight Instance is about a flight number on a specific date. Aircraft list the...

  • May I ask the SQL code as follows? The relational database moviedb has the following database...

    May I ask the SQL code as follows? The relational database moviedb has the following database schema: Movie(title, production year, country, run time, major genre) primary key : {title, production year} Person(id, first name, last name, year born) primary key : {id} Award(award name, institution, country) primary key : {award name} Restriction Category(description, country) primary key : {description, country} Director(id, title, production year) primary key : {title, production year} foreign keys : [title, production year] ⊆ Movie[title, production year] [id]...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT