For Problem 2.3, I’m uncertain how to go about transforming the ER diagram into a relational schema. Do you have any suggestions?
Start by reviewing the slides on pages 26-34 of the coursepack. They outline the basic procedures for transforming an ER diagram into a relational schema, as well as a number of special cases that can affect how many tables you need and what their primary keys should be. In addition:
page 33 discusses foreign keys
page 34 gives a relational schema for the university database and discusses the foreign keys that are present in those tables.
Finally, in Lab 1, Task 1, we derived a relational schema from the ER diagram for the airline information database, and we recommend reviewing the solutions for that task.
For Problem 2.3, do we need to worry about capturing participation constraints?
No. It typically isn’t possible to capture participation constraints when converting an ER diagram to a relational schema.
However, you should include a description of any participation constraints in your answer to problem 2.2.
Are we allowed to look up details that are not specified in a given problem (e.g., the ID number of a given person or movie) so that we can use them in our queries?
No. The only literal values that your queries may include are ones that are specified in the text of the problem that you are solving.
I’m having trouble with one of the problems. Do you have any suggestions on how I should proceed?
First, make sure that you are following the rules of thumb that we discussed in lecture.
Next, try looking at the example queries in the notes and labs for queries that solve a problem that is similar to the one that you’re stuck on, and use those queries as models.
In particular:
The solutions to the practice problems from pages 116-124 of the coursepack are available in the Lectures folder for 2/6 on Blackboard.
The solutions to Lab 2 are available on the Labs page.
Also, when writing join conditions, don’t forget that these are based on the foreign keys and primary keys in the relevant tables. Consult the schema of the tables to remind yourself of what the keys are.
For one of my queries, it seems like I am getting too many results. Do you have any suggestions?
Make sure that you have enough join conditions (for N tables, you
need N-1 join conditions), and that each table in the FROM clause
is part of at least one of the join conditions.
For some of the SQL problems, it seems like we could either use
a SELECT command with multiple tables in the FROM clause
(i.e., a join of some sort) or a SELECT command with one or more
subquery. Do you have a preference about which approach we use?
For the purposes of PS 1, we would recommend using multiple tables
in the FROM clause whenever possible so that you can get the
necessary practice with this type of query. However, there may be
one or more problems for which a subquery is unavoidable, and you
should of course use one in such cases.
I’m not getting any results at all for one of my queries, and I don’t understand why. Do you have any suggestions?
If you are performing pattern matching, make sure that you use the
LIKE operator, rather than =. Also, make sure that you include the
necessary wildcard characters (% and/or _).
SQLite seems to allow me to combine a column name with an aggregate in the SELECT clause – even when I’m not grouping by that column. Is it okay if I do this in one of my answers?
No! You are correct that SQLite allows this, but it is not standard SQL. You should write a query that follows the rules for SQL mentioned in the lecture notes so that it will work on any relational DBMS. In particular, you may want to consider using a subquery to obtain the result that you’re looking for.
I’m having trouble with problem 10. Do you have any additional hints?
One possible model for this problem is found in the lecture notes
on LEFT OUTER JOIN. In those notes, we considered the problem of
finding the ID and the major(s) of every student enrolled in a
course, including enrolled students with no major. In order to
include students without a major, we needed to use a LEFT OUTER
JOIN, so that students in the Enrolled table who didn’t appear in
the MajorsIn table would still be included in the result. You need
to do something similar in problem 11 to ensure that people born
in Ireland who have not won any of the Oscars in the database are
still included in the result.
I’m having trouble with problem 11. Do you have any additional hints?
A good model for this problem is practice problem 5 on page 120 – the one in which we are looking for all students who are not enrolled in a course. In that case, we used a subquery to find the ids of students who are enrolled in a course, and then we used the NOT IN operator to find students whose ids were not in the result of the subquery. You will need to do something similar here.
Another good model is question 2 from the extra practice problems on page 122 that we reviewed in lecture.
In SQL, we specify an explicit join condition for an outer join. Are we allowed to do that in relational algebra?
Yes. In the same way that you can do a regular theta join that includes an explicit join condition, you can also do an outer join with an explicit join condition.
I’m stuck on 16.3. Do you have any hints?
Yes! Here are three hints:
Make sure to use the hint that is already in the problem:
Hint: Take advantage of the set difference operator (-).
You may find it helpful to consult Lab 2. There is a problem that we solved both using SQL and relational algebra in which the relational-algebra version also requires the use of the set difference operator.
Last updated on February 7, 2026.