Solutions to Final Examination

Similar documents
Solutions to Final Examination

A7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

Database Management Systems Paper Solution

NJIT Department of Computer Science PhD Qualifying Exam on CS 631: DATA MANAGEMENT SYSTEMS DESIGN. Summer 2012

Techno India Batanagar Computer Science and Engineering. Model Questions. Subject Name: Database Management System Subject Code: CS 601

Examination paper for TDT4145 Data Modelling and Database Systems

Section 1: Redundancy Anomalies [10 points]

Fundamentals of Database Systems

Database Management Systems (Classroom Practice Booklet Solutions)

DATABASE MANAGEMENT SYSTEMS

SOLUTIONS TO THE FINAL EXAMINATION Introduction to Database Design Spring 2011

Attach extra pages as needed. Write your name and ID on any extra page that you attach. Please, write neatly.

CSE344 Final Exam Winter 2017

VANCOUVER ISLAND UNIVERSITY CSCI 370 FINAL EXAMINATION 17 April 2009, 13:00 16:00

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

Babu Banarasi Das National Institute of Technology and Management

Total No. of Questions :09] [Total No. of Pages : 02. II/IV B.Tech. DEGREE EXAMINATIONS, NOV/DEC Second Semester CSE/IT DBMS

COMP7640 Assignment 2

CS6302- DATABASE MANAGEMENT SYSTEMS- QUESTION BANK- II YEAR CSE- III SEM UNIT I

Introduction to Database Systems. Announcements CSE 444. Review: Closure, Key, Superkey. Decomposition: Schema Design using FD

Name :. Roll No. :... Invigilator s Signature : DATABASE MANAGEMENT SYSTEM

Database Management

Comp 5311 Database Management Systems. 14. Timestamp-based Protocols

CSE 344 Final Examination

SYED AMMAL ENGINEERING COLLEGE

SCHEMA REFINEMENT AND NORMAL FORMS

Bachelor in Information Technology (BIT) O Term-End Examination

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

Homework 6: FDs, NFs and XML (due April 13 th, 2016, 4:00pm, hard-copy in-class please)

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization

Midterm Exam (Version B) CS 122A Spring 2017

Example Examination. Allocated Time: 100 minutes Maximum Points: 250

Introduction. Examination, INF3100, No examination support material is allowed


CSIT5300: Advanced Database Systems

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

Midterm 2: CS186, Spring 2015

Examination examples

Database System Concepts

CS2255 DATABASE MANAGEMENT SYSTEMS QUESTION BANK UNIT I

Rajiv GandhiCollegeof Engineering& Technology, Kirumampakkam.Page 1 of 10

Part VIII Transactions, Integrity and Triggers

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

CSE 444, Winter 2011, Midterm Examination 9 February 2011

Normalization. Murali Mani. What and Why Normalization? To remove potential redundancy in design

CMSC 461 Final Exam Study Guide

MIDTERM EXAMINATION Spring 2010 CS403- Database Management Systems (Session - 4) Ref No: Time: 60 min Marks: 38

Graph-based protocols are an alternative to two-phase locking Impose a partial ordering on the set D = {d 1, d 2,..., d h } of all data items.


Homework 3: Relational Database Design Theory (100 points)

SYED AMMAL ENGINEERING COLLEGE

In This Lecture. Exam revision. Main topics. Exam format. Particular topics. How to revise. Exam format Main topics How to revise

The University of British Columbia

Transactions and Concurrency Control. Dr. Philip Cannata

MaanavaN.Com DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING QUESTION BANK

Concurrency Control. Concurrency Control Ensures interleaving of operations amongst concurrent transactions result in serializable schedules

Transaction Management. Chapter 14

E-R diagrams and database schemas. Functional dependencies. Definition (tuple, attribute, value). A tuple has the form

Schema And Draw The Dependency Diagram

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization

Northern India Engineering College, New Delhi Question Bank Database Management System. B. Tech. Mechanical & Automation Engineering V Semester

Advanced Databases (SE487) Prince Sultan University College of Computer and Information Sciences. Dr. Anis Koubaa. Spring 2014

[18 marks] Consider the following schema for tracking customers ratings of books for a bookstore website.

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

Functional Dependencies CS 1270

Database System Concepts

Transactions These slides are a modified version of the slides of the book Database System Concepts (Chapter 15), 5th Ed

Chapter 15: Transactions

Sankalchand Patel College of Engineering, Visnagar B.E. Semester III (CE/IT) Database Management System Question Bank / Assignment

(At most 8 combina7ons of B,C,D composite values) AND (BCDà E) means (At most 8 values for E)

Exam. Question: Total Points: Score:

Transactions. Prepared By: Neeraj Mangla

Data Analysis. CPS352: Database Systems. Simon Miner Gordon College Last Revised: 12/13/12

Sample Exam for CSE 480 (2016)

Functional Dependencies and Finding a Minimal Cover

VIEW OTHER QUESTION PAPERS

CSE 530A ACID. Washington University Fall 2013

Birkbeck. (University of London) BSc/FD EXAMINATION. Department of Computer Science and Information Systems. Database Management (COIY028H6)

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

Database Management

COSC Dr. Ramon Lawrence. Emp Relation

Database System Concepts

In This Lecture. Normalisation to BCNF. Lossless decomposition. Normalisation so Far. Relational algebra reminder: product

Chapter 14: Transactions

Implementing Isolation

Unit 3 : Relational Database Design

L Information Systems for Engineers. Final exam. ETH Zurich, Autumn Semester 2017 Friday

Solutions. Updated of 7

CSCE 4523 Introduction to Database Management Systems Final Exam Spring I have neither given, nor received,unauthorized assistance on this exam.

Database Management Systems Written Exam

ICOM 5016 Database Systems. Chapter 15: Transactions. Transaction Concept. Chapter 15: Transactions. Transactions

COMP302. Database Systems

NAPIER UNIVERSITY SCHOOL OF COMPUTING FIRST DIET (SEMESTER TWO) EXAMINATION SESSION CS 71012: DATABASE SYSTEMS TIME ALLOWED: 2 HOURS

(All chapters begin with an Introduction end with a Summary, Exercises, and Reference and Bibliography) Preliminaries An Overview of Database

Chapter 8: Relational Database Design

Database Administration and Tuning

CSIT5300: Advanced Database Systems

Chapter 13: Transactions

Transactions. Lecture 8. Transactions. ACID Properties. Transaction Concept. Example of Fund Transfer. Example of Fund Transfer (Cont.

Chapter 16. Relational Database Design Algorithms. Database Design Approaches. Top-Down Design

Transcription:

Prof. Li-Yan Yuan CMPUT 391: Database Management Systems Solutions to Final Examination April 23, 2007 It is a close-book examination and the time for the test is 120 minutes. There are ten (10) questions over two (2) pages. The value of each question is indicated in [ ] and the total is 100. Good luck to all of you. 1. Indicate whether each of the following statements is TRUE or FALSE. Each correct answer worths 4 points while an incorrect answer leads to the deduction of 2 points. [16] (a) Statement: The K-means algorithm is used in clustering because the number of clusters (categories) to be determined is known in advance. Solution: FALSE. (b) Statement: The ID3 algorithm for data classification is guaranteed to terminate. Solution: TRUE. (c) The two phase locking protocol uses rollbacks to resolve deadlock while the timestamps protocol uses rollback to resolve starvation. Solution: FALSE. (d) Statement: The FOR clause of XQuery is used to declare variables and bind each variable to its range. Solution: TRUE. 2. Consider a database with the following two tables with obvious meanings course(course id, course name, no credit), registration(student id, course id, grade). Note that the underlined attributes are keys of the tables. Write the triggers for imposing the following foreign key constraint specified in the CREATE TABLE statement for registration: [12] FOREIGN KEY (course id) REFERENCES course ON DELETE CASCADE. To enforce the foreign key constraint, both the deletion on course and the update/insertion on registration must be monitored. Consequently, the following two triggers are needed: One is to implement the DELETE CASCASE: CREASTE TRIGGER reference_constraint_on_course AFTER DELETE OR UPDATE ON COURSE FOR EACH ROW BEGIN IF (UPDATE AND NEW.course_id <> OLD.course_id OR DELETE) DELETE registration WHERE course_id = OLD.course_id; END; One is to make sure any registed course is indeed recoreded in the course table. CREASTE TRIGGER foregin_key_on_registration BEFORE INSERT OR UPDATE ON registration FOR EACH ROW DECLARE counter INT BEGIN 1

SELECT COUNT(*) INTO counter FROM course WHERE course_id = NEW.course_id; IF (counter < 1 ) THEN raise_exception( the foreign key constraint violated END; 3. Consider a relation schema R = ABCDE, functional dependencies B E E A A D D E and a decomposition D = {AB, BCD, ADE} of R. Is D dependency preserving? Explain. [6] Solution: Yes, D is dependency preserving. This is because D is equivalent to D = {B A, E A, A D, D E}, and D is dependency preserving. 4. Consider the database schema R = ABCDEF, and the following FDs: ABF C CF B CD A BD AE C F (a) Find a minimal cover of the given set of FDs. Show all steps. Solution: i. Right reducing: Replace BD AE with BD A and BD E. ii. Left reducing: ABF C can be replaced with: AB C while CF B can be replaced with: C B. This is because (1) AB C is entailed by ABF C and ; and C B is entailed by CF B and C F; (2) AB C entails ABF C and C B entails CF B; and therefore (3) the set AB C, is equivalent to ABF C, ; and C B, C F is equivalent to CF B, C F. That is, after Left-reducing, we have AB C C B CD A BD A BD E C F iii. Eliminate redundant FDs: C F is entailed by C B and, while CD A is entailed by C B and BD A. Therefore, a minimal cover is AB C C B BD A BD E 2

(b) Construct a join lossless, dependency preserving, and 3NF decomposition of R. Solution: The 3NF decomposition that corresponds to this minimal cover is {ABC, CB, BDAE, BF }. Note that BDAE is a super key of R. (c) Are all the schemas in the previous step in BCNF? Explain. [12] Solution: R 1 = ABC is not in BCNF because C B but C is not a key of R 1. All the rest are in BCNF. 5. Consider the database schema R = ABCDE and a set of MVDs M = {AB D}. Prove or disprove that D = {ABE, ABCD} is a join lossless decomposition of R with respect to M. Note that a proof must follow the definitions of the join lossless and MVD while a counter example is sufficient for a disproof. [10] Solution: D is not join lossless with respect to M. Consider the following table r over R. A B C D E a b c d 1 e 1 a b c d 2 e 2 Then r satisfies M but r Π ABE (r) Π ABCD (r). 6. Consider the following database schema with obvious meanings: prof( p id, p name, department) course(c code, department, c name) teaching(p id, c code, term) and the following query SELECT c.c_name, p.p_name FROM prof p, teaching t, course c WHERE t.term = Fall 2007 AND p.department = cs AND p.p_id = t.p_id AND t.c_code = c.c_code (a) Show the unoptimized relational algebra expression that corresponding to the above SQL query. Solution: Π course.c name,prof.p name σ θ (prof teaching course) where θ represents teaching.term = F all 2007 prof.department = cs. (b) Draw the corresponding query tree for the relational algebra expression obtained in the previous step. (c) Draw the query tree obtained from the previous tree by applying the heuristic optimization rules. [10] 7. Consider the following schedule S. T1 T2 T3 T4 write(x) read(y) write(z) write(y) read(z) 3

(a) Draw a precedence graph (serialization graph as called in the text book) for S. Solution: The precedence graph is given below. T1 / \ / \ / \ T2 ---> T3 ---> T4 (b) If S is serializable give an equivalent serial schedule, if not explain why. [10] Solution: Yes, S is serializable and the equivalent serial schedule is T1, T2, T3, T4. 8. Can a deadlock occur in the timestamps concurrency control protocol. [4] Solution: No, a deadlock cannot occur in the timesstamps protocol because no transaction ever needs to wait. 9. The SQL99 specifies four (4) different levels of isolation, i.e., READ UNCOMMITTED, READ COM- MITTED, REPEATABLE READ, and (ANOMALY) SERIALIZABLE. (a) Present a sample schedule S such that S observes READ UNCOMMITTED but not READ COMMITTED. Solution: A schedule with DIRTY READ, shown below, observes observes READ UNCOM- MITTED but not READ COMMITTED. T1 T2 Write(X) Rollback Read(X) (b) Demonstrate that your schedule will not be possible under the two phase locking protocol. The two phase locking protocol prevents T2 from Reading X before T1 rollbacks or commits. Indicate any reasonable assumptions you may have. [10] 10. Given the fact table below: sales(market id, item id, sale) and the following SQL statement: SELECT market_id, item_id, SUM(sale) GROUP BY CUBE (market_id, item_id) Write one SQL statement without using any GROUP BY CUBE clause that returns the same result set as the above SQL statement. [10] Solutions SELECT market_id, item_id, SUM(sale) GROUP BY CUBE market_id, item_id UNION 4

SELECT market_id, NULL, SUM(sale) GROUP BY CUBE market_id SELECT NULL, item_id, SUM(sale) GROUP BY item_id SELECT NULL, NULL, SUM(sale) 5