CSC 202

We finished Chapter 2 and started talking about relations (Section 3.1).

Submission: you can submit the homework to me either by hardcopy in class or email it to me.

1. [SQL Queries, 30pt] For each SQL query, please submit your SQL and a printout of the resulting table. Be careful writing both of these, and make sure you double-check that your output is what you expect it to be.

- [10pt] List courses that were not taught before 2006. (This includes courses that have not been taught at all.) In our database this would list all courses except for CSC 440 and CSC 489 (which were taught in 2005).
- [20pt] List students that have taken courses in all departments. [This one is a bit tricky, review our last SQL examples]. Our university has four departments right now: CSC, IT, GPH and DC (from the course table) and there is no student that has taken courses in all departments, but we can add one, for example:

insert into student

values ('Grenninger', 'Pavel', 67754,
132132132, 'GRD', 'COMP-SCI', 'Chicago', 2001);

insert into enrolled

values (67754, 1092, 'Fall', 2003);

insert into enrolled

values (67754, 9219, 'Winter', 2004);

insert into enrolled

values (67754, 8772, 'Fall', 2005);

insert into enrolled

values (67754, 2987, 'Fall', 2004);

The four departments should not be
hardcoded into the query, but should be

retrieved from the course table.

2. [Symmetric Difference]

The symmetric difference of two sets A and B is defined as A Δ B := (A-B) u (B-A).

- [5pt] Draw a Venn diagram and identify A Δ B in the diagram by shading it.
- [5pt] What does it mean if A Δ B = ø ? Re-express that condition using other terminology we have seen.

3. [Venn diagrams, 10pt]

Draw a Venn diagram for three sets, and label all the (eight) regions with the sets they correspond to (e.g. A n B n C or A n B n C). (see Figure 2.3, page 17 of the week 2 notes for an example on two sets).

4. [Pairs, 5pt] Let A = {1, 2, 3} and B = {Lisa, Bart, Homer}. Compute the Cartesian product A x B. (Double-check the number of elements.)

5. [Powerset, 10pt] Compute

P({Lisa, Bart, Maggie}) - P({Lisa, Bart, Homer}),

where P is the powerset. *Hint*: there is an easy and a hard (well, more
cumbersome) way to do this.

6. [Extra Credit] Can you draw a Venn diagram for four sets? (The sets do not have to be circles, they can be other shapes.) There should be 16 regions.

7. [Extra Credit] If you find any typos and mistakes in the lecture notes, please let me know.

Marcus Schaefer

Last updated: April 17th, 2007.