Docsity

Database Systems Homework 3: Constraints, HDD Capacity, and Indexing, Assignments of Database Management Systems (DBMS)

Toggle sidebar
bg1
CS143: Database Systems
Homework #3
(Due: 2PM 02/12/03)
1. Assume the following database on PCs and PC orders. For every order that a customer places on a
model, a tuple is inserted into the PC-Order table. A customer type is either ‘Business’ or ‘Personal’.
PC(model, speed, ram, hdd, price)
PC-Order(order-id, customer-type, model, quantity)
Using a CHECK constraint on the PC-Order table, express the constraint that a business customer cannot
order a PC model whose price is below $1,000. You do not need to show the entire CREATE TABLE
statement. Show only the CHECK constraint part in the CREATE TABLE statement.
2. In this problem you express a referential integrity constraint using a general SQL assertion. Assume
that there are two tables R(a) and S(a). Using a general SQL assertion, express that S.a is a foreign
key referencing R.a. That is, there should not be any S.a value that does not appear in R.a.
Note that a general SQL assertion is not attached to a particular table. Therefore, whenever a SQL
modification statement is executed that may potentially violate the assertion, the DBMS checks the
result of the statement and rejects the statement if it causes violation. This behavior is the same as
the default semantics of a foreign-key constraint.
3. Assume the following parameters for a hard disk drive:
•4 platters (8 surfaces in total)
•1,000 cylinders
•400 sectors per track and each sector is 512 bytes
•10,000 RPM rotational speed
•average 10ms seek time
For the hard disk described above, answer the following questions. In addition to the answers, please
write the formula that shows how you derived each answer.
(a) What is the capacity of the drive? (Assume a megabyte is 1,000,000 bytes, and a gigabyte is
1,000,000,000 bytes)
(b) What is the average rotational delay?
(c) What is the burst transfer rate of the disk?
(d) What is the average time to read a random sector from the disk?
4. We need to store a table with 5,000,000 records into a disk. A disk block is of size 2048. Each record
in the table consists of the following fields (= attributes): A real of 8 byte, a character string of length
25, and an integer of 4 bytes. How many disk blocks are necessary to store the table? Assume that we
do not span a record over multiple blocks. Show how you derived your answer.
1
pf2

Partial preview of the text

Download Database Systems Homework 3: Constraints, HDD Capacity, and Indexing and more Assignments Database Management Systems (DBMS) in PDF only on Docsity!

CS143: Database Systems

Homework

(Due: 2PM 02/12/03)

  1. Assume the following database on PCs and PC orders. For every order that a customer places on a model, a tuple is inserted into the PC-Order table. A customer type is either ‘Business’ or ‘Personal’.

PC(model, speed, ram, hdd, price) PC-Order(order-id, customer-type, model, quantity)

Using a CHECK constraint on the PC-Order table, express the constraint that a business customer cannot order a PC model whose price is below $1,000. You do not need to show the entire CREATE TABLE statement. Show only the CHECK constraint part in the CREATE TABLE statement.

  1. In this problem you express a referential integrity constraint using a general SQL assertion. Assume that there are two tables R(a) and S(a). Using a general SQL assertion, express that S.a is a foreign key referencing R.a. That is, there should not be any S.a value that does not appear in R.a. Note that a general SQL assertion is not attached to a particular table. Therefore, whenever a SQL modification statement is executed that may potentially violate the assertion, the DBMS checks the result of the statement and rejects the statement if it causes violation. This behavior is the same as the default semantics of a foreign-key constraint.
  2. Assume the following parameters for a hard disk drive:
    • 4 platters (8 surfaces in total)
    • 1,000 cylinders
    • 400 sectors per track and each sector is 512 bytes
    • 10,000 RPM rotational speed
    • average 10ms seek time

For the hard disk described above, answer the following questions. In addition to the answers, please write the formula that shows how you derived each answer.

(a) What is the capacity of the drive? (Assume a megabyte is 1,000,000 bytes, and a gigabyte is 1,000,000,000 bytes) (b) What is the average rotational delay? (c) What is the burst transfer rate of the disk? (d) What is the average time to read a random sector from the disk?

  1. We need to store a table with 5,000,000 records into a disk. A disk block is of size 2048. Each record in the table consists of the following fields (= attributes): A real of 8 byte, a character string of length 25, and an integer of 4 bytes. How many disk blocks are necessary to store the table? Assume that we do not span a record over multiple blocks. Show how you derived your answer.

10 30 50

50

(a) Example for insertion

50

10 20 30 50 60 70

30 70

(b) Example for deletion

Figure 1: Examples for Problem 6

  1. Suppose blocks hold either three records, or ten key-pointer pairs. Assume that the table that we need to store contains n records. As a function of n, show how many blocks we need for each of the following:

(a) The data file (the entire table) (b) A dense index on the data file (c) A sparse index on the data file

  1. (a) Show the B+tree structure after we insert 60, 20, and 80 into Figure 1(a) in the given order.

(b) Show the B+tree structure after we delete 20, 10, and 70 from Figure 1(b) in the given order. (Comments: Be careful with exactly when an underflow occurs.)