Docsity

Quiz 2 for CMSC 424–0201 Fall 2004, Quizzes of Principles of Database Management

Toggle sidebar
bg1
CMSC 424–0201 Fall 2004 Quiz 2 (50 points, 50 minutes) Thu., 18th Nov., 2004
c
°Sudarshan S. Chawathe 2004
Name:
This quiz is open book, open notes, but there can be no sharing of any material, and no
communication except with me. You can use the Internet, but only as a library. If you are
not sure if something is allowed, check with me.
Some questions in this quiz use the database schema and sample instance depicted below.
[The following details are identical to those in quiz 1 and the midterm exam.] The Boxes table
records information about boxes used by a packing store. For each type of box, it stores the
box’s name and supplier, the maximum weight of its contents (in pounds), its price in dollars,
its dimensions (width, depth, and height) in inches, and the number available (inventory).
The Products table records information about products stocked by the packing store for
its customers. For each product, it stores the product name, customer name, weight (in
pounds), and dimensions (as in Boxes). The type of each attribute appears directly below
its name. Primary key attributes are underlined.
When asked for queries, you must provide answers that work for all possible database in-
stances, not just the example instance depicted below. For brevity, relational algebra expres-
sions abbreviate the schemas of the Boxes and Products tables as B(N, S, L, P, W, D, H, I )
and P(N, C, L, W, D, H ), respectively.
The following tables are repeated on the last page of the quiz. You may detach
that page and use it for reference. There is no need to reattach it.
Boxes
name supplier load price width depth height num
varchar(20) varchar(20) float decimal(6,2) float float float integer
small cube box-o-rama 10.5 2.99 24 24 24 100
large cube box-o-rama 20.0 4.99 50 50 50 42
small cube box world 1.0 1.99 8 8 8 22
economy pack box world 1.5 0.99 9 12 0.25 9
Products
pname customer weight width depth height
varchar(20) varchar(20) float float float float
PDR Alice Armstrong 5 8 10 6
bookshelf speaker Bob Beeri 15 24 13 16
1. (1 pt.) Write your name in the space provided above.
1
pf3
pf4
pf5

Partial preview of the text

Download Quiz 2 for CMSC 424–0201 Fall 2004 and more Quizzes Principles of Database Management in PDF only on Docsity!

CMSC 424–0201 Fall 2004 Quiz 2 (50 points, 50 minutes) Thu., 18th Nov., 2004 © c Sudarshan S. Chawathe 2004

Name:

This quiz is open book, open notes, but there can be no sharing of any material, and no communication except with me. You can use the Internet, but only as a library. If you are not sure if something is allowed, check with me. Some questions in this quiz use the database schema and sample instance depicted below. [The following details are identical to those in quiz 1 and the midterm exam.] The Boxes table records information about boxes used by a packing store. For each type of box, it stores the box’s name and supplier, the maximum weight of its contents (in pounds), its price in dollars, its dimensions (width, depth, and height) in inches, and the number available (inventory). The Products table records information about products stocked by the packing store for its customers. For each product, it stores the product name, customer name, weight (in pounds), and dimensions (as in Boxes). The type of each attribute appears directly below its name. Primary key attributes are underlined. When asked for queries, you must provide answers that work for all possible database in- stances, not just the example instance depicted below. For brevity, relational algebra expres- sions abbreviate the schemas of the Boxes and Products tables as B(N, S, L, P, W, D, H, I) and P (N, C, L, W, D, H), respectively. The following tables are repeated on the last page of the quiz. You may detach that page and use it for reference. There is no need to reattach it.

Boxes name supplier load price width depth height num varchar(20) varchar(20) float decimal(6,2) float float float integer small cube box-o-rama 10.5 2.99 24 24 24 100 large cube box-o-rama 20.0 4.99 50 50 50 42 small cube box world 1.0 1.99 8 8 8 22 economy pack box world 1.5 0.99 9 12 0.25 9

Products pname customer weight width depth height varchar(20) varchar(20) float float float float PDR Alice Armstrong 5 8 10 6 bookshelf speaker Bob Beeri 15 24 13 16

  1. (1 pt.) Write your name in the space provided above.
  1. (4 pts.) Write a SQL statement that creates the table Boxes, introduced earlier. Include a declaration for the primary key.
  2. (5 pts.) Suppose the table Products, introduced earlier, has already been created and populated with some data, such as the data in the sample instance. Write a SQL statement that declares the primary key of Products without dropping the table or otherwise losing its contents.
  1. (5 pts.) Suppose we wish to disallow insertions of boxes that are strictly dominated by some existing box. Write a SQL trigger on the Boxes table that enforces this requirement.
  2. (5 pts.) A project group has a name, a letter grade, a contact phone number, and consists of zero or more students. Write an ODL declaration of a class that models project groups. (Chose appropriate types.) You may assume the existence of a class, Student, that models students.
  1. (5 pts.) Suppose all transactions in a database system are running at SQL isolation level L. If the following history is observed, what are the possible values of L? Justify your answer briefly. (The history follows the notational conventions used in class.)

r^1 (x) r^2 (x) c^2 r^1 (x) r^3 (y) w^1 (y) a^1 r^3 (x) w^3 (x) c^3

  1. (5 pts.) Write a SQL statement to create a table Customers with attributes name, phone, and balance, where balance refers to an account balance for the customer, and may be a credit or debit balance. Declare a foreign-key constraint that requires every customer name in Products to also occur in Customers.

Scratch page

Material here will not be graded. You may detach and discard this page.

Boxes name supplier load price width depth height num varchar(20) varchar(20) float decimal(6,2) float float float integer small cube box-o-rama 10.5 2.99 24 24 24 100 large cube box-o-rama 20.0 4.99 50 50 50 42 small cube box world 1.0 1.99 8 8 8 22 economy pack box world 1.5 0.99 9 12 0.25 9

Products pname customer weight width depth height varchar(20) varchar(20) float float float float PDR Alice Armstrong 5 8 10 6 bookshelf speaker Bob Beeri 15 24 13 16