IPT home IPT A Virtual Approach by Peter Whitehouse
Quick Links:
 
 
IIS home
Information and Intelligent Systems Social and Ethical Implications Human Computer Interaction Software and Systems Engineering eXercise Files Course Outline and Assessment A-Z of Geeky Acronyms Terrace Work Program 2004 Sillybus FAQ = Frequently Asked Questions Help
 
 

SQLEX15 - The BLOCKBUSTER Database

The Blockbuster database contains managment information from a Video Hire outlet (you may remember the notion of hiring a video to watch - 'twas the way of days past) for your delight and edification.

You can CREATE this database for yourself by getting the MySQL Script and running it in your copy of PHPMyAdmin

You can use My Query Engine Page (or more interestingly create your own)

This activity contains additional SQL exercises for practice. The questions are based on the following database for a classic movie hire franchise.


Movie       (movieId, movname, minutes, yr, dirId)
Director    (dirId, dirname, country)
Member    (memberId, memname, address, owes)
Onhire      (movieId, memberId, duedate)

In Movieminutes is the length of the movie in minutes, yr is the year the picture was made.
In Directorcountry is the country of origin of the director.
In Memberowes is the amount not yet paid for movie hire.

All fields are text except length and year (number), owes (currency) and duedate (date).

Write queries for each of the following based on the Blockbuster database.

  1. List all details about club members.
  2. Which movies (id) are currently on hire?
  3. What are the names of the movies and in which year were they made?
  4. List the members (ids) who currently have a movie out (no repeats).
  5. What country does the director David Lean come from?
  6. In what year was Star Wars made?
  7. What is the name and address of member number 5045?
  8. Which members owe more than $50?
  9. List the non American directors.
  10. What is the movieid and title of the movies less than 180 minutes in length?
  11. Which members currently do not owe anything?
  12. Which movies were made in the 1970s?
  13. List the movie (id) hired by member 5034 and due back on 14th of September.
  14. List members who owe between $50 and $100.
  15. Which movie by director 107 does not run for 137 minutes?
  16. Which movie(s) over 200 minutes were made before 1960?
  17. List the north American (US and Canada) directors.
  18. Use in in a query to list the English, German and French directors.
  19. List the members whose name begins with an F.
  20. Which members live at addresses that are streets (end in St)?
  21. List the directors called John.
  22. Which movies made after 1990 begin with M?

Use subqueries to complete the following:

  1. What country is the director of Casablanca from?
  2. What is the name and address of the member hiring movie 1015?
  3. How much is owed by the member with videos due on 6th of September?
  4. Who directed Glory?
  5. Which movies (numbers) are on hire to members who do not owe anything?
  6. What movies (names) are being hired by R Miller?
  7. What is the address of the member who has Full Metal Jacket on hire?
  8. List the directors of movies due back on the 12th of September.

In the questions that follow you may or may not need subqueries:

  1. Add 10% GST to amounts owing.
  2. How many years ago was each movie made (current year – year made)?
  3. With 12 minutes of trailers (adverts) before each movie, how long would the tape for each run?
  4. There has been a clerical error. In a query reduce each due date by two days.
  5. List all movies and length of time in hours.
  6. List movies in alphabetical order.
  7. List movies in order, longest first.
  8. List directors by alphabetical order of country and then within each country list the directors in alphabetical order.
  9. List movie names in order of being made. Within each year list the longest movie first.
  10. List members and amounts owing. (Do not list members who do not owe anything.)
  11. List in order of movie number, the number and name of movies on hire.
  12. List in order of age, the names of movies due back on the 12th of September.
  13. What is the total amount currently owing?
  14. What is the average length of movies?
  15. How many movies were made before 1980?
  16. How many members owe money?
  17. What is the name of the longest movie?
  18. What is the average amount owing by members who owe money?
  19. What is the shortest movie made by Steven Spielberg?
  20. What movies (names) are on hire to the member who currently owes the most?
  21. List the members who owe more than the average.
  22. How many movies are due on each date?
  23. How many directors are from each country?
  24. Which year had most movies made?

Use joins to write the following queries:

  1. How much is owed by members who currently have movies on hire? List in order of amount owing.
  2. List directors of movies made in 1986 or 1987.
  3. What is the name and address of members who have movies due on or before the 8th of September?
  4. Who currently has Zulu on hire?
  5. What are the names of the movies on hire to the member who currently owes the most?
  6. Who directed the movie L. Austin has on hire?
  7. List any movies by a director that are the same length in time.
  8. What are the names of movies that are rented by members who have more than one movie due on the same day?

solutions

 

wonko@wonko.info
©Copyright 1992..2018+. Edition 26.150117
wonkosite
Creative Commons License
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 2.1 Australia License
.