CS50 for MBAs
SQL
Learning Objectives
DB Browser for SQLite
movies.db
Tables
What are the titles of all of the movies in which Kevin Bacon (b. 1958) starred?
What are the titles of all of the movies in which Kevin Bacon (b. 1958) starred?
What are the titles of all of the movies in which Kevin Bacon (b. 1958) starred?
What are the titles of all of the movies in which Kevin Bacon (b. 1958) starred?
Nested SELECTs
SELECT title FROM movies WHERE id IN�(SELECT movie_id FROM stars WHERE person_id =�(SELECT id FROM people WHERE name = "Kevin Bacon" and birth = 1958));
Implicit JOINs
SELECT title FROM movies, stars, people WHERE�people.name = "Kevin Bacon" and people.birth = 1958 AND�stars.person_id = people.id AND�stars.movie_id = movies.id;
Explicit JOINs
SELECT title FROM movies �JOIN stars ON movies.id = stars.movie_id�JOIN people on stars.person_id = people.id WHERE�people.name = "Kevin Bacon" and people.birth = 1958 AND�stars.person_id = people.id AND�stars.movie_id = movies.id;
IMDb Questions and Answers
Movies
References
submit what you've done so far
practice problems
CS50 for MBAs
SQL