Part I due by 11:59 p.m. on Tuesday, September 15, 2026
Part II due by 11:59 p.m. on Tuesday, September 22, 2026
If you haven’t already done so, you should complete Lab 0 before beginning this assignment.
In your work on this assignment, make sure to abide by the collaboration policies of the course. Unless they are labeled pair-optional, the problems in this assignment are individual-only problems that you must complete on your own.
If you have questions, please come to office hours, post them on
Piazza, or email cs460-staff@cs.bu.edu.
Make sure to submit your work on Gradescope, following the procedures found at the end of Part I and Part II.
30 points total
If you haven’t already created a folder named cs460 for your
work in this course, follow these
instructions to do so.
Then create a subfolder called ps1 within your cs460 folder,
and put all of the files for this assignment in that folder.
Recommended: Configure your browser so that it asks you where each downloaded file should be saved. Both Chrome and Edge allow you to do this as follows:
The problems from Part I will all be completed in a single PDF file. To create it, you should do the following:
Make sure you are signed into your BU Google Drive account. Note that signing into BU Google Mail should accomplish the same thing.
Access the template that we have created by clicking on this link.
When asked, click on the Make a copy button, which will save a copy of the template file to your Google Drive.
Select File->Rename, and change the name of the file to
ps1_partI.
Add your work for the problems from Part I to this file.
Once you have completed all of these problems, choose
File->Download->PDF document, and save the PDF file in your ps1
folder. The resulting PDF file (ps1_partI.pdf) is the one that you
will submit. See the submission guidelines at the end of Part I.
10 points total
Important
This problem, like most of the problems in this assignment, is individual-only. In general, unless a problem or section of an assignment is explicitly labeled as pair-optional, you should assume that it is individual-only. See our collaboration policies for details about both types of problems.
Before going any further, make sure to follow the instructions above to create your own copy of the Google Drive document that you should use for Part I of the assignment.
The ER diagram shown below is part of the design of a database that
includes information about actors and the parts that they perform in
plays, musicals, movies and TV shows. Each actor has a name and a
unique id. Each part can be uniquely identified by the combination of
the id of the corresponding show and the name of the role, and the
database also keeps track of how many lines of dialogue that each part
has (the attribute called line count).

In the above version of the ER diagram, there are no constraints on the relationships between actors and parts.
In the ps1_partI template that we’ve provided on Google Drive (see
above), we’ve included the beginnings of three separate versions of
this ER diagram.
(2 points) Edit the first version of the diagram, adding the connections needed to create an ER diagram whose only constraint is that every actor performs at most one (i.e., 0 or 1) part. To do so, you should:
Click on the diagam and then click the Edit link that appears below the diagram.
From the collection of eight connectors that we have provided below the diagram, select the appropriate connectors and use them to connect the two entity sets to the relationship set. Adjust the connectors as needed to make the connections.
Click the Save & Close button.
(2 points) Edit the second version of the diagram, adding the connections needed to create an ER diagram whose only constraint is that every actor performs exactly one part.
(2 points) Edit the third version of the diagram, adding the connections needed to create an ER diagram whose only constraints are (1) that every actor performs at least one part, and (2) that every part is performed by at most one actor.
(4 points) Consider your answer to part 1—the ER diagram for the situation in which every actor performs at most one part.
Is it possible to convert that diagram into a relational schema that has only two tables/relations, or would three be needed? Explain your answer briefly, and then specify the schema of the two or three tables.
Give the schema of each table in the form relation_name(attr_name1, attr_name2, ...).
Indicate the primary-key attribute(s) of each relation by underlining them.
12 points total
The ER diagram shown below in Figure 2-1 represents information that is to be stored in a database for a literary agency—i.e., a company that provides agents for authors.
Figure 2-1:

Note that the diagram includes relationship sets for three types of relationships:
Answer the following questions about this diagram:
(2 points) At least one of the relationship sets captures a many-to-one relationship. Which one(s)? In your answer, you should specify the direction of each such relationship (e.g., ________ is many-to-one from _________ to ___________).
(4 points) Fill in the table that we have provided to describe, for each relationship set in the diagram, any constraints on the relationships associated with that relationship set. Use words that describe the problem domain (e.g., Each course meets in at most one room...) rather than technical terminology.
(6 points) Transform this diagram into a relational schema by following the procedure discussed in lecture and fill in the table that we have provided. Here are some additional guidelines:
When appropriate, you should combine relations as discussed in lecture.
In the first column of the table, give the schema of each
relation in the form relation_name(attr_name1, attr_name2,
...). Feel free to rename attributes as needed to make them
easier to understand. However, if you do so, make sure that
you do not use a period or space in an attribute name.
Rather, you should use a combination of letters and underscore
(_) characters.
Indicate the primary-key attribute(s) of each relation by underlining them.
If a relation has one or more foreign-key attributes, specify them in the second column of the table, and specify which attribute each foreign key refers to. For example, if you were working with the MajorsIn relation from the university database covered in lecture, its foreign keys would be specified as follows:
8 points total; 2 pts. each part
We will finish the material needed for this problem in lecture on Friday, September 11.
Relation R has attributes a, b and c. Relation S has attributes a, b, and d. You are given the following instances of these relations:
Relation R
|
a |
b |
c |
|---|---|---|
|
1 |
2 |
3 |
|
3 |
4 |
3 |
|
7 |
6 |
5 |
Relation S
|
a |
b |
d |
|---|---|---|
|
2 |
3 |
1 |
|
3 |
4 |
9 |
|
7 |
6 |
4 |
For each of the following questions, use the Insert->Table menu option in Google Drive to insert an appropriately sized table for the answer, and then fill in the cells of the table with the correct values.
Make sure that each table includes a header row with appropriate column names.
Once you have completed Part I in Google Drive, choose
File->Download->PDF document, and save the resulting file
(ps1_partI.pdf) in your ps1 folder.
Login to Gradescope by clicking the link in the left-hand navigation bar. When logging in, make sure that you use the School Credentials option and select Boston University.
Once you are in logged in, click on the box for CS 460. (If
you don’t see that box, email cs460-staff@bu.edu ASAP and ask to
be added to the course on Gradescope. If the deadline is fast
approaching and you don’t have access to CS 460 on Gradescope,
email your PDF to cs460-staff@cs.bu.edu before the
deadline.)
Click on the name PS 1: Part I in the list of assignments. You should see a pop-up window labeled Submit Assignment. (If you don’t see it, click the Submit or Resubmit button at the bottom of the page.)
Choose the Submit PDF option, and then click the Select PDF
button and find the ps1_partI.pdf that you created in step 1.
Then click the Upload PDF button.
You should see a question outline along with thumbnails of the pages from your uploaded PDF. For each question in the outline:
As you do so, click on the magnifying glass icon for each page and doublecheck that the pages that you see contain the work that you want us to grade.
Once you have assigned pages to all of the problems in the question outline, click the Submit button in the lower-right corner of the window. You should see a box saying that your submission was successful.
You can use the Resubmit button at the bottom of the page to resubmit your work as many times as needed before the final deadline.
Important
It is your responsibility to ensure that the correct version of a file is on Gradescope before the final deadline. We will not accept any file after the submission window for a given assignment has closed, so please check your submission carefully using the steps outlined above.
If you are unable to access Gradescope and there is enough
time to do so, wait an hour or two and then try again. If you
are unable to submit and it is close to the deadline, email
your homework before the deadline to
cs460-staff@cs.bu.edu
70 points total
The problem domain for this part of the assignment is movie trivia.
Before you get started, you should carefully read over the full description of the database. Please do so now!
If you haven’t already done so, download and install DB Browser for SQLite by following these instructions.
Download the following files into your ps1 folder:
If your browser doesn’t allow you to specify where the file should be saved, try right-clicking on the link above and choosing Save as... or Save link as..., which should produce a dialog box that allows you to choose the correct folder for the file.
Launch the program.
Click the Open Database button, and find and open the movie.sqlite
database file that you downloaded above.
To explore the schema of the database, click on the Database Structure tab, and then click on the arrows to the left of the table names.
To explore the contents of the tables, click on the Browse Data tab, and then choose the appropriate table from the drop-down menu.
Use the Execute SQL tab to perform queries on the database. Enter your SQL command in the space provided, and press F5 or Ctrl-R to run it. (There is also a small button that you can click; it has a triangular shape that looks like the Play button of a music player.)
ps1_queries.py is a Python file, so you could use a Python IDE
to edit it, but a regular text editor like TextEdit or Notepad++
would also be fine. However, if you use a text editor, you must
ensure that you save it as a plain-text
file.
Construct the SQL commands needed to solve the problems given below. Test each SQL command in DB Browser for SQLite to make sure that it works.
Once you have finalized the SQL command for a given problem, copy
the command into your ps1_queries.py file, putting it between
the triple quotes provided for that problem’s variable. We have
included a sample query to show you what the format of your
answers should look like.
Unless otherwise stated, each of the problems must be solved by means of a single query (i.e., each query should have a single semi-colon). Use nested subqueries in the WHERE clause as needed. However, you should NOT use nested subqueries in the SELECT clause or FROM clause.
You must limit yourself to aspects of SQL that we have discussed in lecture, unless the problem indicates otherwise. At a minimum, failure to do so will result in a score of 0 for the corresponding problem. See our course policies for more detail.
Your queries should not use a LIMIT clause.
Your queries should only use the keyword DISTINCT if it is
necessary to obtain the correct results. Similarly, you should
only use an outer join when it is strictly necessary.
Make sure that the results produced by your queries contain exact answers to the problems. We should not have to infer the answer from the results. For example, if we ask you how many movies meet a given criterion, we want a number, not a list of the movies. In addition, your results should not include any extraneous information.
4 points
Important
Make sure to read the important guidelines above before you get started! In particular, note that you may only use aspects of SQL that we have discussed in lecture, and you should NOT use nested subqueries in the SELECT clause or FROM clause.
Two types of movies related to Marvel comic strips have done extremely well at the box office: Spider-Man movies and Avengers movies. Write a single query to find the name and earnings rank of each Spider-Man movie and each Avengers movie. The result of the query should be tuples of the form (name, earnings rank).
Your query should use pattern matching, and it should assume that:
All movies from the Spider-Man franchise have the string
'Spider-Man' (including the hyphen) somewhere in their name –
but not necessarily at the beginning.
All movies from the Avengers franchise have the word
'Avengers' somewhere in their name – but not necessarily at the
beginning.
Hints:
If your initial query does not produce any results, you may want
to reconsider the logical operator (AND, OR, NOT) that you
are using in your WHERE clause.
At least one of the movies in the results will have a value of NULL for its earnings rank. That just means that the movie is not one of the top 200 grossing movies.
4 points
Tom Holland has starred as Spider-Man in the most recent live-action Spider-Man movies, but other actors played the role in the earlier movies. In particular, Andrew Garfield is a former Spider-Man. Write a single query to find the name and year of his Spider-Man movies – i.e., the Spider-Man movie or movies for which our database includes the fact that Andrew Garfield acted in those movie(s). The result of the query should be tuples of the form (name, year). Note that the assumption given in the previous problem about the names of the Spider-Man movies also holds here.
4 points
Horror movies have been doing very well at the box office, so
movie studios have been producing a lot of them! Write a single query
to find the most recent horror movie(s) in our database – i.e., the
horror movie or movies whose year is the largest. If multiple horror
movies are tied for the largest year, your query should retrieve all
of them. You should assume that any horror movie has the letter 'H'
somewhere in the value of its genre attribute. The results of your
query should be tuples of the form (name, year).
4 points
It seems likely that some movie ratings should tend to have shorter movies than others. For example, you might guess that G-rated movies – which are often aimed at children – would typically be shorter than R-rated ones. Write a query to determine, for each movie rating, the shortest runtime, longest runtime and average runtime of the movies with that rating. You should exclude movies with a NULL rating, as well as any movie rating that is associated with fewer than 10 of the movies in our database. The result of the query should be tuples of the form (rating, shortest runtime, longest runtime, average runtime). Sort the results in descending order by average runtime.
4 points
Most but not all of the older movies in our database were included because they won one or more Oscars. Write a query that determines how many Oscars were won by each movie in the database released before 1940. The result of the query should be tuples of the form (movie name, number of Oscars). If a movie has won no awards, it should still appear in the table with a value of 0 for the number of Oscars.
Notes:
You may assume that all movies before 1940 have a unique name.
The year in which a movie wins an Oscar is typically one year later than the year in which the movie was released. For example, a movie that won an Oscar in 2026 was released in 2025.
If a movie wins two Oscars of the same type (e.g., two Best Director Oscars), each of those Oscars should contribute to the count for that movie.
4 points
Write a query to determine the number of actors in the database who have not acted in any of the movies in the database from the past decade (i.e., 2016 or later). The result of the query should be a single number.
4 points
Jessie Buckley is an Irish actress who just won the Best Actress Oscar for her role in Hamnet. Write a query to determine the number of people born in Ireland who have won any of the Oscars in our database. The result of the query should be a single number.
Hints:
You should assume that all people born in Ireland have a pob
value that ends with the string 'Ireland'.
It’s possible that there are currently no repeat Oscar winners from Ireland. However, your query should work even if there were repeat winners from there.
4 points
Write a query to determine how many of movies with an R rating have runtimes that are shorter than the average runtime of all of the movies in the database. The result of your query should be a single number. Hint: You will need a subquery.
4 points
Find all places of birth in Massachusetts that are the hometown of
one or more Oscar winners. You should assume that all places of birth
from Massachusetts end with the string 'Massachusetts, USA'.
A given city or town should appear at most once in the results.
4 points
Write a query to find the name and date of birth of the youngest director in the database – i.e., the one whose date of birth is closest to today. If multiple directors are tied for being the youngest, your query should include all of them. The results of your query should be tuples of the form (person name, date of birth).
5 points
Write a query that summarizes the Oscars won by the horror movies in
our database. Your results should contain tuples of the form (movie
year, movie name, award type). If a given horror movie won multiple
awards, it should have one tuple for each award; if it has not won any
awards, it should have a single tuple in which the last value of the
tuple is NULL. As stated in an earlier problem, any horror movie
has the letter 'H' somewhere in the value of its genre
attribute. The results of your query should be sorted:
in descending order by the movie year
then (for years with multiple results), in ascending order by movie name
then (for movies with multiple awards), in ascending order by type.
5 points
Write a query to find all movies that have won at least 4 of the Oscars in the database. The results of your query should be tuples of the form (movie name, number of Oscars, year in which the Oscars were won). Sort the results in descending order by the number of Oscars won. If multiple movies are tied for number of Oscars, sort them in ascending order by name.
Notes:
There are movies in the database that have the same name, but you should assume that the combination of name and year (both movie name and movie year and movie name and Oscar year) is unique.
When creating subgroups, you are allowed to use more than one attribute as the basis of the subgroups.
The year in which a movie wins an Oscar is typically one year later than the year in which the movie was released. For example, a movie that won an Oscar in 2026 was released in 2025.
If a movie wins two Oscars of the same type (e.g., two Best Director Oscars), each of those Oscars should contribute to the count for that movie.
20 points total; 4 points each part; pair-optional
This is the only problem of the assignment that you may complete with a partner. See the rules for working with a partner on pair-optional problems for details about how this type of collaboration must be structured.
Getting started
Your work on this problem should go in a separate PDF file called
ps1_problem16.pdf. To create it, you should:
Access the template that we have created by clicking on this link and signing into your Google account as needed.
When asked, click on the Make a copy button, which will save a copy of the template file to your Google Drive.
Select File->Rename, and change the name of the file to
ps1_problem16.
Add your work for this problem to this file.
When you are finished, choose File->Download->PDF document, and
save the PDF file on your machine. The resulting PDF file
(ps1_problem16.pdf) should be submitted following the
instructions below.
The problems
See below for some additional guidelines.
Write a relational-algebra query for problem 4 (Marvel-ous earnings). You may assume that relational algebra includes the same pattern-matching operators as SQL.
Write a relational-algebra query for problem 12 (Oscar-winning Mass hometowns).
Write a relational-algebra query for problem 14 (Oscars for horror movies). You don’t need to sort the results.
Write a relational-algebra query for problem
9 (inactive actors), but
instead of producing a count, your query should produce the ids of
the actors. Hint: Take advantage of the set difference
operator (-).
Your friend claims that the previous problem could be solved without performing set difference. Explain briefly why an approach based solely on a theta join of Actor and Movie (and a subsequent projection) would not work for this problem.
Additional guidelines
To form your queries, you should use the templates that we have
provided for each of the relational-algebra operators at the top
of ps1_problem16. Copy the appropriate template(s), and replace
the placeholders with the appropriate expressions, attributes
and/or predicates to form each query. We have provided an example
in ps1_queries of using two of the templates to form a single
query.
For a given problem, you are allowed to perform a sequence of two
or more queries in which the results of a given query are assigned
to a variable using the assignment operator (<–), and then that
variable is used in a subsequent query. We have provided an
example of this in ps1_queries, and we recommend that you do
this whenever a given query would otherwise become too long or
difficult to read.
Note that using a sequence of queries is not allowed in your SQL answers, but it is allowed here.
You will make submissions to two separate assignments on Gradescope. The steps needed for the two submissions are different, so please make sure to follow carefully the procedures outlined below.
PS 1: Problems 4-15
Submit your ps1_queries.py file using these steps:
Click on the name of the assignment in the list of assignments. You should see a pop-up window with a box labeled DRAG & DROP. (If you don’t see it, click the Submit or Resubmit button at the bottom of the page.)
Add your file to the box labeled DRAG & DROP. You can either drag and drop the file from its folder into the box, or you can click on the box itself and browse for the file.
Click the Upload button.
You should see a box saying that your submission was successful.
Click the (x) button to close that box.
The Autograder will perform some tests on your file. Once it is done, check the results to ensure that the tests were passed. If one or more of the tests did not pass, the name of that test will be in red, and there should be a message describing the failure. Based on those messages, make any necessary changes. Feel free to ask a staff member for help.
Notes:
You will not see a complete Autograder score when you submit. That is because additional tests for at least some of the problems will be run later, after the final deadline for the submission has passed. For such problems, it is important to realize that passing all of the initial tests does not necessarily mean that you will ultimately get full credit on the problem. You should always run your own tests to convince yourself that the logic of your solutions is correct.
If you get a message saying that the Autograder failed to
execute correctly, it is likely the case that one of your
queries is taking too long to execute. Make sure that you have
checked each query in DB Browser to ensure that it executes
correctly, and that you have copied the correct query into
your ps1_queries.py file. If you have a query that is
causing DB Browser to hang, you should either remove that
query from your file before submitting it, or you should
comment it out by putting a # symbol at the beginning of
each of line of the query.
If needed, use the Resubmit button at the bottom of the page to resubmit your work.
Near the top of the page, click on the box labeled Code. Then click on the name of your file to view its contents. Check to make sure that it contains the queries that you want us to grade.
PS 1: Problem 16
IMPORTANT: If you chose to work on problem 16 with a partner, only one person from the pair should submit the file, and that person should add the other person as a group member following step 6 below.
Submit your ps1_problem16.pdf file using these steps:
If you still need to create a PDF file, open your file
on Google Drive, choose File->Download->PDF document, and
save the PDF file in your ps1 folder.
Click on the name of the assignment in the list of assignments on Gradescope. You should see a pop-up window labeled Submit Assignment. (If you don’t see it, click the Submit or Resubmit button at the bottom of the page.)
Choose the Submit PDF option, and then click the Select PDF button and find the PDF file that you created. Then click the Upload PDF button.
You should see a question outline along with thumbnails of the pages from your uploaded PDF. For each question in the outline:
As you do so, click on the magnifying glass icon for each page and doublecheck that the pages that you see contain the work that you want us to grade.
Once you have assigned pages to all of the questions in the question outline, click the Submit button in the lower-right corner of the window. You should see a box saying that your submission was successful.
If you worked with a partner and you are the one who is submitting the file:
Click on the Group Members link that appears at the bottom of the page.
In the pop-up box that appears, click on the Add Student drop-down menu.
Type your partner’s name or choose it from the drop-down menu.
Click the Add button.
Check to ensure that your partner’s name now appears along with your name under the Group heading in the upper-right corner of the page.
Important
It is your responsibility to ensure that the correct version of every file is on Gradescope before the final deadline. We will not accept any file after the submission window for a given assignment has closed, so please check your submissions carefully using the steps outlined above.
If you are unable to access Gradescope and there is enough
time to do so, wait an hour or two and then try again. If you
are unable to submit and it is close to the deadline, email
your homework before the deadline to
cs460-staff@cs.bu.edu
Last updated on September 17, 2026.