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.
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).
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.