Database Management Systems s3
Total Page:16
File Type:pdf, Size:1020Kb
CS 370 / IT 376 Exam 2 Page 1 Database Management Systems Fall 2003 11/5/03 Name______
1. True/False. [20 pts] ______Normalization attempts to eliminate redundant facts stored in a database. ______All redundancy can be eliminated in a relational database. ______Multi-valued attributes require multiple attributes, e.g., several columns representing hobbies. ______Formal definitions of relational databases call for all values to be non-null. ______Update and deletion anomalies have to do with malformed relations that contain two or more facts per tuple. ______Functional dependencies in general cannot be discovered by an algorithm. ______Transitivity of functional dependencies means that if a →b and a→c then b→c. ______Decomposition of FDs mean that if a→bc then a→b and a→c ______Closure (a+) states that if a is a superkey, then a+ should determine the whole relation. ______A canonical cover of FDs is a minimal set of FDs in which closure still determines the relation. ______A lossless join decomposition is one that when the decomposed relations are rejoined, the original relation cannot be recovered. ______3NF relations do not contain any transitive dependencies ______3NF relations do not contain FDs between non-key and a subkey ______Not all 3NF relations can be decomposed to BCNF ______Statement level interface for embedded SQL requires a compiler preprocessor and extensions to the syntax of the language. ______Embedded SQL in Java we used through the java.sql.* package is an example of statement level interface. ______The SQLSTATE system variable is a 5 digit string that contains standard return codes. ______A Terabyte is approximately a trillion bytes. ______Disk accesses are rated in milli-seconds.
2. Give two interpretations of the use of the “null” value in a relation. [4 pts] CS 370 / IT 376 Exam 2 Page 2 3. Explain what the following SQL statement does and when it is invoked. [5 pts] CREATE TRIGGER MaxEnrollCheck BEFORE INSERT ON Transcript REFERENCING NEW AS N --row to be added FOR EACH ROW WHEN ((SELECT COUNT (T.StudId) FROM Transcript T WHERE T.CrsCode = N.CrsCode AND T.Semester = N.Semester) >= (SELECT C.MaxEnroll FROM Course C WHERE C.CrsCode = N.CrsCode )) ABORT TRANSACTION
4. Cursors. [8 pts] a. What are their purpose in embedded SQL?
b. What is a forward-only cursor?
c. What is a scroll-sensitive cursor?
5. Explain the use of ROLLBACK and COMMIT in the context of a logical transaction. What starts a logical transaction in a database? [5 pts] CS 370 / IT 376 Exam 2 Page 3
6. Given the relation schema Customer(CID, CustName, OrderID, Address, PhoneNum, OrderDate, OrderTotal, ItemID, ItemPrice, ItemName, Quantity) and the functional dependencies below, first show the minimum cover of the functional dependencies. Apply 3NF decomposition based on your minimal cover and give the resulting relations. CID→CustName, Address (CID,OrderID)→OrderDate OrderID →CID, OrderTotal (OrderID,ItemID)→ItemPrice,Quantity ItemID→ItemPrice, ItemName Phone → CID Phone →CustName [8 pts] Minimal cover (show your work and explain FD removals):
[7 pts] Decomposition (underline keys): CS 370 / IT 376 Exam 2 Page 4
7. Explain the function of each of the following JDBC objects for embedded SQL database access. [11 pts] Driver Manager:
Connection:
Prepared Statement:
Result Set:
SQLException:
8. 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 6 buckets for the sequence of keys in the order given. Use simple linear searching for collisions into full buckets. 1, 3, 5, 7, 11, 13, 17, 19, 24, 29, 39, 43 [8 pts] 0 1 2 3 4
9. Extendible Hashing. [6 pts] a. What advantage is there to using extendible hashing?
b. Why is the generated hash value a full 32 bit integer?
c. What disadvantage is there to the extendible hashing file structure? CS 370 / IT 376 Exam 2 Page 5
10. Construct a B+-tree for the following key values: 2, 17, 5, 7, 29, 11, 3, 13, 19, 23, 31 assuming that the tree is initially empty, values are kept in ascending order and the number of values that will fit in one node is 3. [8 pts]
11. A disk contains 8 surfaces, 16 tracks per cylinder, 256 sectors per track, 1500 cylinders and 1024 bytes per sector. There 8 bits per bytes. What is the capacity of the disk in giga-bytes? [4 pts]
12. Given the following information, what is the average access time function for reading or writing a sector of a disk? 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. There are 50 sectors per track. [6 pts]