Fall 2004
CS 370 / IT 376 Exam 2
Page 1
Database Management Systems
1. True/False.
[15 pts]
______ Statement level interface for embedded SQL requires a compiler preprocessor and extensions to
the syntax of the language.
______ A call level interface for embedded SQL does not permit reference to host language (e.g. Java)
______ Embedded SQL in Java we used through the java.sql.* package is an example of a call level
______ The SQLSTATE system variable is a 5 digit string that contains return codes that vary across
programming languages.
______ A Petabyte is approximately a trillion bytes.
______ Disk accesses are roughly a thousand times slower than RAM access.
______ ODBC is a language independent database access protocol.
______ Generalization and specialization representations in an EER diagram look similar.
______ A cylinder on a disk is partially defined by the number of read/write heads attached to the
______ A heap or pile file maintains the data in order by primary key.
______ A table stored as a B+-tree may only have the primary key as an index.
______ An object oriented database schema may define methods in addition to attributes and
______ Student subentities such as (freshman, sophomore, junior, senior) are an example of an
overlapping specialization.
______ A EER relationship constraint (2,M) next to entity A connected to entity B means that there is at
least two instances of A related to an instance of entity B.
______ Extendible hashing eliminates the need to rehash a file to accommodate a larger data set.
2. Give two interpretations of the use of the “null” value in a relation.
[4 pts]
3. Explain the use of ROLLBACK and COMMIT in the context of a logical transaction.
[3 pts]
Fall 2004
CS 370 / IT 376 Exam 2
Page 2
4. The following SQL statements are crucial components to successfully accessing a database from
Java. Numerically rank the statements in the order that they would need to occur (in the source
but most importantly in execution) in a typical Java program. Give a brief explanation in general
of what the statement accomplishes.
[20 pts]
Java Statement
Connection con = DriverManager.
getConnection(Url, Id,
ResultSet res = stat.executeQuery
Class.forName (“com.mysql.
String query = “SELECT T.StudId
FROM Transcript T WHERE
T.CrsCode= ‘”+ course + ”’
AND T.Semester= ‘” + sem +
import java.sql.*;
Statement stat =
con.CreateStatement ();
while ( res.next() ) {
j = res.getInt (“StudId”);
…process output value…
5. Disk drives.
a. A disk contains 8 surfaces, 1 read/write head per cylinder, 512 sectors per track, 2048
cylinders and 1024 bytes per sector. There 8 bits per byte. What is the capacity of the
disk in giga-bytes?
[4 pts]
b. The shortest seek time is 1 msec and the longest (full movement from outer to inner cylinder)
is 9 msec. The disk spins one revolution in 2 msec. What is the average access time for
reading or writing an entire track in one read operation from the above disk?
[4 pts]
c. To read an entire track, how much memory would have to be allocated for a double buffer so
that the next track can be read while the current one is being processed?
[2 pts]
Fall 2004
CS 370 / IT 376 Exam 2
Page 3
6. Suppose we are using simple hashing with a bucket size of 3 and the hash function is
h(x) = x mod 5. Show the contents of the 5 buckets for the sequence of keys in the order given.
Use simple linear searching for collisions into full buckets.
1, 3, 5, 6, 9, 11, 19, 20, 21, 24, 26, 32, 39
[8 pts]
7. Construct the index nodes for the B+-tree below. The number of values that will fit in one node
is 3. For degree = 3, you can have index nodes with just one key in it. For level 1, assume that
you have two nodes, the first nodes indexes the left three data nodes and the second node indexes
the right two. Then the root node indexes the two nodes at level 1 (hint: select your key value
from the data node)
[8 pts]
Root level
Level 1:
Data Nodes: (2-3-5)
(17-19-23) (30-35-38) (40-43-45)
Now show what happens when you insert the value 44.
Fall 2004
CS 370 / IT 376 Exam 2
Page 4
For the remaining questions, use the following bookstore database schema. Keys are underlined. ISBN
is the unique book ID number. The rest of the attributes should be self-evident. If not, please
ask for clarification.
CUSTOMER (CID, Name, Street, Zip, CreditLimit)
BOOK(ISBN, Title, Author, CopiesOnHand, Price, PBID)
PURCHASED(ISBN,CID, DatePurchase, Copies)
BACKORDER(ISBN, CID, Copies, HomePhone)
PUBLISHER(PBID, Name, Street, Zip)
CSZ (Zip, City, State)
Syntax for SQL, where [] means optional, {op1|op2|...} means choice
SELECT [DISTINCT] {* | attribute-list | aggregate functions}...
FROM tables-list and aliases | LEFT JOIN table alias ON join-condition
WHERE condition
[GROUP BY attr [HAVING condition]]
SQL conditions consist of <,>,<=,>=, <>,=, AND, OR, BETWEEN value AND value
[NOT] EXISTS ({list | SELECT...}),
rel-op {ANY|SOME|ALL} ({ list | SELECT...}), IS [NOT] NULL
Aggregate functions: COUNT(*), MIN(attr), MAX(attr), SUM(attr), AVG(attr)
8. Give the SQL select statements for the following queries.
[20 pts]
a) List all customers by name and city from the state of Maryland (coded as ‘MD’).
b) List the zip codes on record in which there are no customers from. (Hint use LEFT JOIN or
c) List all book titles of which there are more than 3 backordered customers. (Hint use GROUP
d) List publishers who have backordered books on order.
Fall 2004
CS 370 / IT 376 Exam 2
Page 5
9. In the table below, indicate for EER modeling and for OODB modeling how you would consider
each of the tables in the bookstore database to be represented. For EER, would you represent the
corresponding table as an ENTITY or RELATIONSHIP? For the OODB, would you represent
the table as a CLASS or a RELATIONSHIP in the class? Put your choices “ENTITY”, “CLASS”
or “RELATIONSHIP” in the spaces
[12 pts]