Name Class Account UNIVERISTY OF CALIFORNIA, BERKELEY College of Engineering Department of EECS, Computer Science Division J.

Similar documents
CSE 444, Winter 2011, Midterm Examination 9 February 2011

INSTITUTO SUPERIOR TÉCNICO Administração e optimização de Bases de Dados

ACID Properties. Transaction Management: Crash Recovery (Chap. 18), part 1. Motivation. Recovery Manager. Handling the Buffer Pool.

Crash Recovery. The ACID properties. Motivation

Slides Courtesy of R. Ramakrishnan and J. Gehrke 2. v Concurrent execution of queries for improved performance.

Crash Recovery. Chapter 18. Sina Meraji

Transaction Management: Crash Recovery (Chap. 18), part 1

some sequential execution crash! Recovery Manager replacement MAIN MEMORY policy DISK

Transactions and Recovery Study Question Solutions

Atomicity: All actions in the Xact happen, or none happen. Consistency: If each Xact is consistent, and the DB starts consistent, it ends up

Crash Recovery CMPSCI 645. Gerome Miklau. Slide content adapted from Ramakrishnan & Gehrke

Database Administration and Tuning

CSE 444 Midterm Exam

CAS CS 460/660 Introduction to Database Systems. Recovery 1.1

Database Recovery Techniques. DBMS, 2007, CEng553 1

Review: The ACID properties. Crash Recovery. Assumptions. Motivation. More on Steal and Force. Handling the Buffer Pool

A tomicity: All actions in the Xact happen, or none happen. D urability: If a Xact commits, its effects persist.

The transaction. Defining properties of transactions. Failures in complex systems propagate. Concurrency Control, Locking, and Recovery

DATABASE MANAGEMENT SYSTEMS

ARIES (& Logging) April 2-4, 2018

UNIT 9 Crash Recovery. Based on: Text: Chapter 18 Skip: Section 18.7 and second half of 18.8

Introduction. Storage Failure Recovery Logging Undo Logging Redo Logging ARIES

Crash Recovery Review: The ACID properties

Last time. Started on ARIES A recovery algorithm that guarantees Atomicity and Durability after a crash

Database Management Systems Paper Solution

Concurrency Control & Recovery

Introduction to Data Management. Lecture #18 (Transactions)

Introduction to Data Management. Lecture #26 (Transactions, cont.)

COURSE 4. Database Recovery 2

Introduction to Database Systems CSE 444

Transaction Management Overview

Concurrency Control & Recovery

Outline. Purpose of this paper. Purpose of this paper. Transaction Review. Outline. Aries: A Transaction Recovery Method

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Final Review

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Database Systems: Fall 2008 Quiz I

Transaction Management Overview. Transactions. Concurrency in a DBMS. Chapter 16

CSE 530A ACID. Washington University Fall 2013

CS122 Lecture 18 Winter Term, All hail the WAL-Rule!

Aries (Lecture 6, cs262a)

AC61/AT61 DATABASE MANAGEMENT SYSTEMS JUNE 2013

Goals for Today. CS 133: Databases. Final Exam: Logistics. Why Use a DBMS? Brief overview of course. Course evaluations

CS/B.Tech/CSE/New/SEM-6/CS-601/2013 DATABASE MANAGEMENENT SYSTEM. Time Allotted : 3 Hours Full Marks : 70

Database Applications (15-415)

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Administrivia. Last Class. Faloutsos/Pavlo CMU /615

CSE344 Final Exam Winter 2017

CS122 Lecture 19 Winter Term,

IMPORTANT: Circle the last two letters of your class account:

Overview of Transaction Management

Topics in Reliable Distributed Systems

Final Review. May 9, 2017

Final Review. May 9, 2018 May 11, 2018

Advances in Data Management Transaction Management A.Poulovassilis

COMPSCI/SOFTENG 351 & 751. Strategic Exercise 5 - Solutions. Transaction Processing, Crash Recovery and ER Diagrams. (May )

Database Recovery. Lecture #21. Andy Pavlo Computer Science Carnegie Mellon Univ. Database Systems / Fall 2018

Introduction to Data Management. Lecture #25 (Transactions II)

In these relations, vin is a foreign key in ORDER referring to the CAR relation, and techid is a foreign key

Intro to Transaction Management

Midterm 2: CS186, Spring 2015

CSE 544, Winter 2009, Final Examination 11 March 2009

CSE 190D Database System Implementation

User Perspective. Module III: System Perspective. Module III: Topics Covered. Module III Overview of Storage Structures, QP, and TM

Problems Caused by Failures

CISC437/637 Database Systems Final Exam

Database Tuning and Physical Design: Execution of Transactions

CS 564 Final Exam Fall 2015 Answers

CSE 190D Spring 2017 Final Exam

CSE 444: Database Internals. Lectures 13 Transaction Schedules

COURSE 1. Database Management Systems

Review: The ACID properties. Crash Recovery. Assumptions. Motivation. Preferred Policy: Steal/No-Force. Buffer Mgmt Plays a Key Role

Lecture 16: Transactions (Recovery) Wednesday, May 16, 2012

Last time: Saw how to implement atomicity in the presence of crashes, but only one transaction running at a time

CISC437/637 Database Systems Final Exam

ARIES. Handout #24. Overview

CSE 544 Principles of Database Management Systems. Fall 2016 Lectures Transactions: recovery

CS 5614: Transaction Processing 121. Transaction = Unit of Work Recall ACID Properties (from Module 1)

L i (A) = transaction T i acquires lock for element A. U i (A) = transaction T i releases lock for element A

Database Systems CSE 414

CS 186 Databases. and SID:

CSE 444, Fall 2010, Midterm Examination 10 November 2010

CSE 344 MARCH 25 TH ISOLATION

CMPS 181, Database Systems II, Final Exam, Spring 2016 Instructor: Shel Finkelstein. Student ID: UCSC

CHAPTER 3 RECOVERY & CONCURRENCY ADVANCED DATABASE SYSTEMS. Assist. Prof. Dr. Volkan TUNALI

Databases - Transactions

CSE 444: Database Internals. Lectures Transactions

Database Management Systems CSEP 544. Lecture 9: Transactions and Recovery

The University of British Columbia Computer Science 304 Practice Final Examination

CSE 344 Final Examination

Final Exam CSE232, Spring 97

For more Articles Go To: Whatisdbms.com CONCURRENCY CONTROL PROTOCOL

CSE 344 Final Review. August 16 th

IMPORTANT: Circle the last two letters of your class account:

Module 15: Managing Transactions and Locks

Databases - Transactions II. (GF Royle, N Spadaccini ) Databases - Transactions II 1 / 22

6.830 Lecture Recovery 10/30/2017

UNIVERSITY OF CALIFORNIA Department of EECS, Computer Science Division. Final Exam: Introduction to Database Systems

Database Management System

MASSACHUSETTS INSTITUTE OF TECHNOLOGY

CPSC 310: Database Systems / CSPC 603: Database Systems and Applications Final Exam Fall 2005

Homework 7: Transactions, Logging and Recovery (due April 22nd, 2015, 4:00pm, in class hard-copy please)

CMSC 461 Final Exam Study Guide

Transcription:

Do not write in this space CS186 Spring 2001 Name Class Account UNIVERISTY OF CALIFORNIA, BERKELEY College of Engineering Department of EECS, Computer Science Division J. Hellerstein Final Exam Final Exam: Introduction to Database Systems This exam has seven problems, each worth a different amount of points. Each problem is made up of multiple questions. You should read through the exam quickly and plan your time-management accordingly. Before beginning to answer a question, be sure to read it carefully and to answer all parts of every question! You must write your answers on the exam. You also must write your name at the top of every page, and you must turn in all the pages of the exam. Do not remove pages from the stapled exam! Extra answer space is provided in case you run out of space while answering. If you run out of space, be sure to make a forward reference to the page number where your answer continues. Good luck! Transaction Management and Locking 1. [15 Points] You have been hired as a consultant to the US Government, to decide which database system to buy for the National Institute of Health. You are considering products from three database companies: Andacle, Notacle, and JCN. Each company has sent you their top technical architect to tell you about their system. All three use fancy terminology, but that does not mean they know what they are talking about! Your job is to determine which companies clearly do not know what they are talking about. Some of the following statements that you hear are wrong, some are right. For each one, circle whether it is wrong or right. If it is wrong, give a counterexample. If it is right, explain briefly. (over ) 1

a. Because we use the Two-Phase Locking protocol (2PL) in JCN, deadlocks can never occur in our system. Wrong Right b. Notacle uses Strict Two Phase Locking Protocol, and therefore we can ensure there will be no cascading aborts. Wrong Right c. Our lock manager in Andacle uses shared and exclusive locks, which guarantees that all schedules in our system are serializable. Wrong Right 2

2. [15 points] Commercial SQL systems actually let you relax serializability, by controlling the locking mode that is used by a transaction. By default, transactions run with Strict Two-Phase Locking (2PL), but you can explicitly set up a transaction to run in a relaxed mode. In this question you will be given a brief description of different relaxed locking modes, and asked about conflicts. Recall that conflicts occur between two transactions that are running at the same time and touch the same data objects. There may be zero, one, two or three correct answers in each part! a. Transactions running in Read Committed mode obtain all locks in the same way as Strict 2PL, and release exclusive locks at the end-of-transaction just like Strict 2PL. However, these transactions release shared locks immediately after finishing a read. Said differently, Read Uncommitted transactions use Short-Term S-Locks, and Strict 2-Phase X-Locks. Which of the following conflicts can occur between a Read Committed transaction, and a transaction following the Strict 2PL locking protocol: Write-Write Read-Write Write-Read b. Transactions running in Read Uncommitted mode always read data without setting any locks in the lock table. These transactions always set exclusive locks before writing as usual, and hold them until end-of-transaction. Said differently, Read Uncommitted transactions use No S-Locks, and Strict 2- Phase X-Locks. Which of the following conflicts can occur between a Read Uncommitted transaction, and a transaction following the Strict 2PL locking protocol: Write-Write Read-Write Write-Read c. All SQL lock modes even the relaxed modes use Strict 2-Phase X-Locks. Consider what would happen if a transaction released a shared lock immediately after a read, and released an exclusive lock immediately after a write (Short-Term S-Locks and Short-Term X-Locks). Which of the following could happen in those cases? Write-Write conflicts. Inconsistent data in the database. Deadlocks 3

Functional Dependencies and Decomposition 3. [10 points] Consider the relation R(A, B, C, D), with a legal instance of R as shown below. You have not been told what functional dependencies hold on R, you have only been shown this legal instance. Each statement below can be categorized either as True, False, or Not Enough Information to be sure. Circle one of those 3 categories for each statement, and justify your answers briefly. A B C D 2 2 2 4 2 2 2 2 4 2 2 2 2 4 2 3 4 4 4 8 a. Relation R needs to be decomposed to achieve Third Normal Form. True False NotEnoughInfo b. The functional dependency A C holds for R. True False NotEnoughInfo c. CD is a not a key for R. True False NotEnoughInfo 4

4. [15 points] Consider the relation Student(SSN, Id, Email, NumericGPA, LetterGPA), also known as SIENL. The relation has the following Functional Dependencies (FDs): {S I, I E, E S, N L}. a. Which of the following is the most efficient, correct way to find the keys? Apply Armstrong s Axioms repeatedly until you cannot derive any more FDs. For each FD with right-hand-side equal to SIENL, the corresponding left-hand-side is a key. Find the attribute closures for each of S,I,E,N and L. The keys are those sets of attributes for which the union of their closures is equal to SIELN. Construct a dependency graph and test it for cycles. All nodes on a cycle correspond to a key. b. How many (minimal) keys are there for Student? Explain either by listing the keys, or by a brief explanation. c. Decompose R into BCNF, showing a tree of decompositions. For each step, note the violation you resolve. 5

Logging and Recovery 5. [10 points] A sales representative from Debacle corporation claims that they provide a STEAL/NO-FORCE buffer management policy for efficiency, and do not need any logging in their system to guarantee the ACID properties. As a database expert, you have serious doubts about this. a. What potential problem can happen due to the STEAL policy in Debacle? Briefly explain a scenario in which this happens. b. What potential problem can happen due to the NO-FORCE policy in Debacle? Briefly explain a scenario in which this happens. 6

6. [20 points] Below is the state of a DBMS after a crash. Your job will be to perform recovery according to ARIES (Algorithm for Recovery and Isolation Exploiting Semantics). Follow the procedures on the next page. Database: (PageNo: pagelsn) Transaction Table Dirty Page Table A: 2 B: 3 C: 30 Xact ID status lastlsn page reclsn 1 running 20 A 10 D: 5 E: 40 F: 7 B 20 2 running 30 C 30 Master Log Record LSN of last checkpoint = 35 Log: xid page prevlsn Type UndoNextLSN Indicate if LSN redone: 10 1 A (null) Update (null) 20 1 B 10 Update (null) 30 2 C (null) Update (null) 35 (null) (null) (null) Begin checkpoint (null) 40 3 E (null) Update (null) 50 2 (null) 30 Commit (null) 60 3 D 40 Update (null) 70 2 (null) 50 End (null) 80 1 C 20 Update (null) 90 1 (null) 80 Commit (null) 100 3 E 60 Update (null) 105 See tables above End checkpoint (null) 110 120 130 140 150 160 170 180 190 200 (over ) 7

a. Analysis. Do analysis to correctly fill out the Transaction and Dirty Page Tables. You may find that you re scratching things out as you go please try to be neat so we can read the final state of the tables. b. Redo. Perform redo to repeat history. Put a mark in the rightmost column of the log next to each update log record that you must redo in the database during this phase. c. Undo. Perform undo. For your answer, please add the appropriate log entires while undo is being performed, but do not modify the tables you filled in for Analysis (so that we can see what you did in part (a)). d. At the end of Undo, what would the real transaction table have in it? 8

7. [15 points] You are building an e-commerce application. Suppose you have four tables: ShoppingCarts(CartID, CustomerID, ExpirationTime): 10,000 rows, 500 pages. CustomerID is a foreign key to Customers. CartContents(CartID, ProductID): 50,000 rows, 2,000 pages. CartID is a foreign key to ShoppingCarts, ProductID is a foreign key to Products. Products(ProductID, name, description, manufacturer, price): 100,000 rows, 10,000 pages Customers(CustomerID, name, address, phone): 200,000 rows, 10,000 pages There are a number of common queries in your application. One produces a checkout page for a customer (whose ID is represented by the variable CUSTVAR): SELECT * FROM ShoppingCarts INNER JOIN CartContents INNER JOIN Products INNER JOIN Customers C WHERE C.CustomerID = CUSTVAR Another common query is to create a shopping cart (the Values are filled in by the application depending on what the customer ID is, what the time of day is, etc.) INSERT INTO ShoppingCarts Values ( ) A third common query is to add a product to a cart (again, the Values are filled in by the app): INSERT INTO CartContents Values ( ) The final common query deletes a shopping cart (whose ID is represented by the variable CARTVAR): DELETE FROM ShoppingCarts WHERE CartID = CARTVAR The computer you re running on is also running a number of other processes, so you can only support a buffer pool that is 200 pages large. Hence you cannot expect any of your tables to fit into the buffer pool. (over ) 9

a) Provide CREATE TABLE statements for the tables ShoppingCarts and CartContents. You may assign types as you see fit. Be sure that integrity constraints are maintained. Also, ensure that all the common transactions are able to run to completion (i.e. they don t have to be aborted)! (over ) 10

b) Assume that each transaction works as follows: an existing customer creates a cart, adds five existing products to the cart, generates a checkout page, and deletes the cart. Given this workload, for each of the following indexes say whether they should be built (YES/NO), and justify why or why not. Be sure to justify all the details of the indexes you think should be built! A clustered B+-tree index on CartContents.ProductID A linear hash index on Customers.CustomerID A linear hash index on ShoppingCarts.CartID A clustered B+-tree index on ShoppingCarts.CustomerID A clustered B+-tree index on ShoppingCarts.CustomerID A linear hash index on Products.ProductID (over ) 11

c) You are trying to decide between MySQL and Postgres, two different open source DBMSs. One advantage of Postgres over MySQL is that Postgres supports hash joins, sort-merge joins as well as block and index nested-loops joins; MySQL only supports block and index nested-loops joins. Assuming both systems were the same in every other way, would Postgres be faster than MySQL for your workload? Justify your answer. (over ) 12

d) In fact, Postgres has other advantages over MySQL as well. One additional advantage is that Postgres supports row-level locking (i.e. its transaction manager sets locks on individual rows), while MySQL only supports table-level locking (it sets locks on entire tables). Hence in principle Postgres can provide higher concurrency than MySQL in many scenarios. Your friend loves MySQL, and tries to convince you that its locking technique is not a problem for your workload. One of his main arguments is that your checkout page query is a killer query that will effectively force both MySQL and Postgres to run one user at a time to guarantee the ACID properties. Explain why your friend is wrong. 13

14 Name

15 Name

16 Name