CS127 Homework #4

CS127 Homework #4
Due: October 26th, 2016 2:59 P.M.
CS127 Homework #4
Due: October 26th, 2016 2:59 P.M.
Warmup #1
(Textbook Problem 8.21 (modified))
Normalize the following schema, with given constraints, to BCNF.
books(accessionno, isbn, title, author, publisher)
users(userid, name, deptid, deptname)
accessionno → isbn
isbn → title
isbn → publisher
isbn → author
userid → name
userid → deptid
deptid → deptname
Answer:
books(isbn, title, publisher, author)
accession(accessionno, isbn)
users(userid, name, deptid)
departments(deptid, deptname)
Warmup #2
(Textbook Problem 10.11)
How does the remapping of bad sectors by disk controllers affect data-retrieval rates?
Answer:
Remapping of bad sectors by disk controllers reduces data retrieval rates because of the loss of sequentiality amongst the sectors.
Warmup #3
(Textbook Problem 10.15)
Explain why the allocation of records to blocks affects database-system performance significantly.
Answer:
If we allocate related records to blocks, we can often retrieve most, or all, of the requested records by
a query with one disk access. Disk accesses tend to be the bottlenecks in databases; since this allocation
strategy reduces the number of disk accesses for a given operation, it significantly improves performance.
1
CS127 Homework #4
Warmup #4
Due: October 26th, 2016 2:59 P.M.
Textbook Problem 10.17
List two advantages and two disadvantages of each of the following strategies for storing a relational database:
1. Store each relation in one file.
2. Store multiple relations (perhaps even the entire database) in one file.
Answer:
1. Advantages of storing a relation as a file include using the file system provided by the OS , thus
simplifying the DBMS, but incurs the disadvantage of restricting the ability of the DBMS to increase
performance by using more sophisticated storage structures.
2. By using one file for the entire database, these complex structures can be implemented through the
DBMS, but this increases the size and complexity of the DBMS.
Warmup #5
(Textbook Problem 10.22)
Standard buffer managers assume each block is of the same size and costs the same to read. Consider a
buffer manager that, instead of LRU, uses the rate of reference to objects, that is, how often an object has
been accessed in the last n seconds. Suppose we want to store in the buffer objects of varying sizes, and
varying read costs (such as Web pages,whose read cost depends on the site from which they are fetched).
Suggest how a buffer manager may choose which block to evict from the buffer.
Answer:
A cost-aware buffer manager should consider the rate of reference as well as cost of reference. Therefore,
instead of using a least recently used (LRU) heuristic, this new buffer manager will use (number of accesses
in the last n seconds / object size) as the deciding heuristic. It will keep objects that have a lot of accesses
per byte to ensure efficient use of memory.
2
CS127 Homework #4
Due: October 26th, 2016 2:59 P.M.
Problem 6 (To Be Graded)
You’re designing a database for an online service called Vapor. The database should hold customer information, game information and sales. Consider the game sales relation with a schema and FDs as follows
(* represents all columns):
(sale_id, sale_time, game_title, game_publisher, publishers_cut_percentage, quantity, price,
customer_id, address, credit_card_number)
• game title → price
• game title → game publisher
• game publisher → publishers cut percentage
• customer id → address
• customer id → credit card number
• sale id → ∗
Follow the algorithm described in lecture to generate a BCNF decomposition for this schema.
Answer:
sales(sale id, sale time, game title, quantity, customer id)
games(game title, game publisher, price)
publishers(game publisher, publishers cut percentage)
customers(customer id, address, credit card number)
3