
CS 550 DATABASE CONCEPTS. Spring 2003
1. Consider the following database for a college department. Each course
offering may use one of several approved sets of textbooks.
create table course(
cnum char(3),
title varchar(25),
description varchar(325),
primary key (cnum));
create table faculty(
ssn char(9),
name varchar(35),
rank varchar(10),
primary key (ssn));
create table textbook(
isbn char(10),
title varchar(35),
publisher varchar(20),
primary key (isbn));
create table book_set(
bset char(3),
cnum char(3),
primary key (bset,cnum),
foreign key (cnum) references
course);
create table book_set_list(
bset char(3),
cnum char(3),
isbn char(10),
primary key (bset,cnum,isbn),
foreign key (bset,cnum)
references book_set,
foreign key (isbn) references
textbook);
create table can_teach(
ssn char(9),
cnum char(3),
bset char(3), /* set faculty
uses for this course */
primary key (ssn,cnum),
foreign key (ssn) references
faculty,
foreign key (cnum) references
course,
foreign key (bset,cnum)
references book_set));
create table offers(
cnum char(3),
semester char(6), /* spring,
summer, fall */
year char(4),
ssn char(9),
limit integer, /* max enrollment,
and number of books to order */
primary key(cnum,semester,year),
foreign key (ssn,cnum)
references can_teach);
a. draw an entity relationship diagram for this database. All
relationships should be characterized with cardinality and
participation requirements. Be sure to indicate every relationship
implied by the DDL for the database.
b. Write an SQL query that prints the number of copies of each textbook
to order for the courses offered in the Fall 2003 semester. The
table printed should have three columns, ‘Isbn’, ‘Title’, and
‘Quantity’. Note that the same textbook may be used in several
book_sets, even book_sets used for different courses.