Docsity

Database Design: CS 550 Course Materials - Prof. Irwin Levinstein, Assignments of Computer Applications

Toggle sidebar
bg1
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.
pf2

Partial preview of the text

Download Database Design: CS 550 Course Materials - Prof. Irwin Levinstein and more Assignments Computer Applications in PDF only on Docsity!

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. 
  1. Given a certain relation R with attributes A, B, and C, one analyst determined that the functional dependencies F = {ABC, AB} ought to hold. Another analyst argued that the correct set was G = {AB, BC}. Are the analysts in agreement or not? Either prove that the two sets of FDs are equivalent or give an example of a database instance where one holds and the other does not. 
  2. Suppose we have a database relation R for an investment firm consisting of the following attributes B(roker), O(ffice of broker), I(nvestor), S(tock), Q(uantity of stock shares owned by an investor), and D(ividend per share), paid by a stock, with the following functional dependencies: S  D I  B IS  Q B  O a. Give all the (candidate) keys for R. b. Decompose R into 3NF preserving dependencies and with the lossless join property. c. Suppose R is decomposed into ISQD and IBO, what redundancies and anomalies do you foresee? 
  3. An E-R diagram can be viewed as a graph in which entity types are nodes and relationship types are edges. What do the following mean if exhibited by the structure of a given E-R schema of a target domain? a. The graph is disconnected. b. The graph is acyclic.