If, after reading the solutions and error keys, you want to discuss the grading, you should give your exam, with a note, to the relevant person. Ms. Bharwada can deliver these notes and exams if you like.
| Problem | Grader |
|---|---|
| Part 1(a) | Mayank |
| Parts 1(b) & 1(c) | Calvin |
| Parts 2(a) & 2(b) | Karen |
| Parts 2(c) & 2(d) | Grace |
| Problem 3 | Jeff |
The following are acceptable ways of modifying the ER diagram to make it possible:
The following were some of the common errors, and the penalties thereof:
The following are keys to the error codes, as indicated on the corrected answer sheets:
Thus, enumerating the superkeys, we have:
{A,D}, {A,E}, {B,D}, {B,E}, {C,D}, {C,E},
{A,B,D}, {A,C,D}, {A,D,E}, {A,B,E}, {A,C,E}, {B,D,E}, {B,C,D}, {C,D,E}, {B,C,E},
{A,B,C,D}, {A,B,D,E}, {A,C,D,E}, {A,B,C,E}, {B,C,D,E},
{A,B,C,D,E}.
| Relation | Basis |
|---|---|
| R1(A, B) | {B->A, A->B} |
| R2(A, C, D, E) | {A->C, C->A, D->E, E->D} |
| A | B | C | D | E |
|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 |
A1: Checking all pairs, rather than just the inserted tuple against those previously in the relation (-3).
A2: Using an assertion rather than a tuple-based check (-5).
B1: Missing join term (-3).
C1: Forgetting that renaming requires atttributes as well as a new relation name (-1).
C2: Including Articles in the join (-1).
E1: No HAVING clause (-2).
E2: Failing to group by both author and keyword (-2).
E3: Putting an attribute that isn't in the GROUP BY into the SELECT list (-2).
F1: same as C1.
G1: Using = NULL instead of IS NULL (-1).
G2: Using ALTER instead of UPDATE (-3).
G3: Using a trigger (-5).
CHECK(NOT EXISTS(
SELECT *
FROM Articles aa
WHERE dateline = aa.dateline AND author = aa.author
))
SELECT headline
FROM Articles, Keywords
WHERE Articles.ID = Keywords.ID AND keyword = 'Arafat';
R1(ID,k1) := Keywords;
R2(ID,k2) := Keywords;
R3(ID,k3) := Keywords;
R4(ID,k1,k2,k3) := R1 NATURALJOIN R2 NATURALJOIN R3;
R5(ID,k1,k2,k3) := SIGMA_{k1!=k2 AND k2!=k3 AND k1!=k3}(R4);
Answer(ID) := PROJ_ID(R5);
SELECT ID
FROM Articles
WHERE text LIKE '%Pol Pot%';
SELECT author, keyword, MIN(dateline)
FROM Articles, Keywords
WHERE Articles.ID = Keywords.ID
GROUP BY author, keyword
HAVING COUNT(*) >= 3;
R1(ID) = PROJ_{ID}(SIGMA_{keyword="Milosevic"}(Keywords);
MiloAuthors(author) = PROJ_{author}(R1 NATURALJOIN Articles);
AllAuthors(author) = PROJ_{author}(Articles);
Answer(author) = AllAuthors - MiloAuthors;
Notice how important it is that you subtract sets of authors. If you subtract before projecting onto authors, you get only authors whose every article had only keyword ``Milosevic'' or something like that.
UPDATE Articles
SET text = headline
WHERE text IS NULL;
One of the saddest things was people who came up with some really clever ways to detect that a tuple had NULL text, and lost significant amounts of credit for violating the requirement that their solutions be as simple as possible. The fact is that there is a straightforward way, given above, for testing whether a value is NULL.