CS145 Final Examination

Similar documents
CS145 Final Examination

CS145 Midterm Examination

CS145 Midterm Examination

CS145 Midterm Examination

rate name People Consult Topics name rate name People Consult Topics name

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

DATABASE MANAGEMENT SYSTEMS

CS348: INTRODUCTION TO DATABASE MANAGEMENT (Winter, 2011) FINAL EXAMINATION

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

CS W Introduction to Databases Spring Computer Science Department Columbia University

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

CSE344 Final Exam Winter 2017

download instant at The Relational Data Model

Database Management Systems (COP 5725) (Spring 2007)

1 (10) 2 (8) 3 (12) 4 (14) 5 (6) Total (50)

Database Management Systems Paper Solution

Database Management Systems,

ER to Relational Model. Professor Jessica Lin

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

CSE 190D Spring 2017 Final Exam

Database Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra

CHALMERS UNIVERSITY OF TECHNOLOGY Department of Computer Science and Engineering Examination in Databases, TDA357/DIT620 Thursday 27 March 2008, 08:30

CS211 Lecture: Database Querying and Updating

CS275 Intro to Databases

CS634 Architecture of Database Systems Spring Elizabeth (Betty) O Neil University of Massachusetts at Boston

CS143: Relational Model

Relational Databases

RELATIONAL DATA MODEL: Relational Algebra

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 7 Data Modeling with Entity Relationship Diagrams

SQL: Queries, Constraints, Triggers

CS 245 Midterm Exam Winter 2014

CS425 Midterm Exam Summer C 2012

Name: Database Systems ( 資料庫系統 ) Midterm exam, November 15, 2006

CS 245 Midterm Exam Solution Winter 2015

Examination paper for TDT4145 Data Modelling and Database Systems

ARTICLE RELATIONAL ALGEBRA

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

The Next Step: Designing DB Schema. Chapter 6: Entity-Relationship Model. The E-R Model. Identifying Entities and their Attributes.

SQL. Chapter 5 FROM WHERE

The Relational Model

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

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Database Systems: Fall 2008 Quiz I

Schema And Draw The Dependency Diagram

II. Structured Query Language (SQL)

Database Management Systems (COP 5725) Homework 3

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

CS2300: File Structures and Introduction to Database Systems

Assignment 6: SQL III Solution

Fundamentals of Database Systems

CSE344 Midterm Exam Winter 2017

ITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION

Chapter 6: Entity-Relationship Model. The Next Step: Designing DB Schema. Identifying Entities and their Attributes. The E-R Model.

Relational Model. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

Transaction Management Chapter 11. Class 9: Transaction Management 1

One Size Fits All: An Idea Whose Time Has Come and Gone

Computer Science Applications to Cultural Heritage. Relational Databases

Database Systems Management

Databases-1 Lecture-01. Introduction, Relational Algebra

Exam I Computer Science 420 Dr. St. John Lehman College City University of New York 12 March 2002

CS2300: File Structures and Introduction to Database Systems

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

An Introduction to Structured Query Language

The Basic (Flat) Relational Model. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

CSE 344 Final Examination

CS143 Final Fall 2009

Midterm Exam #2 (Version B) CS 122A Spring 2018

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

CSE 190D Spring 2017 Final Exam Answers

CS 186/286 Spring 2018 Midterm 1

ECE 650 Systems Programming & Engineering. Spring 2018

Chapter 6: RELATIONAL DATA MODEL AND RELATIONAL ALGEBRA

DATABASE MANAGEMENT SYSTEM

The Relational Model Constraints and SQL DDL

A7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

CS 338: Computer Applications in Business: Databases

Assignment 6: SQL III

CS 582 Database Management Systems II

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

CS143 Midterm Spring 2014

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:

Set theory is a branch of mathematics that studies sets. Sets are a collection of objects.

Conceptual Design. The Entity-Relationship (ER) Model

King Fahd University of Petroleum and Minerals

Integrity and Security

SQL DDL. CS3 Database Systems Weeks 4-5 SQL DDL Database design. Key Constraints. Inclusion Constraints

SQL: Queries, Constraints, Triggers (iii)

Query optimization. Elena Baralis, Silvia Chiusano Politecnico di Torino. DBMS Architecture D B M G. Database Management Systems. Pag.

Unit 2. Unit 3. Unit 4

Transactions Processing (i)

CSE 444, Winter 2011, Midterm Examination 9 February 2011

2.2.2.Relational Database concept

CPS221 Lecture: Relational Database Querying and Updating

Introduction to Computer Science and Business

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

An Introduction to Structured Query Language

CS 405G: Introduction to Database Systems

CSCD43: Database Systems Technology. Lecture 4

COMP Instructor: Dimitris Papadias WWW page:

ACS-3902 Fall Ron McFadyen 3D21 Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition)

CPS221 Lecture: Relational Database Querying and Updating

Transcription:

CS145 Final Examination Spring 2003, Prof. Widom ffl Please read all instructions (including these) carefully. ffl There are 11 problems on the exam, with a varying number of points for each problem and subproblem for a total of 120 points to be completed in 120 minutes. You should look through the entire exam before getting started, in order to plan your strategy. ffl The exam is closed book and closed notes, but you may refer to your three pages of prepared notes. ffl Please write your solutions in the spaces provided on the exam. Make sure your solutions are neat and clearly marked. You may use the blank areas and backs of the exam pages for scratch work. Please do not use any additional scratch paper. ffl Simplicity and clarity of solutions will count. You may get as few as 0 points for a problem if your solution is far more complicated than necessary, or if we cannot understand your solution. NAME: In accordance with both the letter and spirit of the Honor Code, I have neither given nor received assistance on this examination. SIGNATURE: Problem 1 2 3 4 5 6 7 8 9 10 11 TOTAL Max. points 15 8 12 10 8 18 5 8 18 10 8 120 Points 1

1. UML (15 points) Consider the following UML design: Worked quarter year StaffMember PKEY name email {complete, disjoint} Class PKEY code dept 1..* Assigned 0..5 TA office officehours SecLeader PKEY sec# time In 1..* Student PKEY ID studname 0..* Took 1..* TookInfo quarter year grade On the next page, fill in up to seven relations for a relational schema generated from this UML design: ffl If you don t use all seven relations, cross out the unused ones. ffl Specify the set of attributes for each generated relation. ffl Underline a key for each generated relation. ffl Assume no attributes in the UML classes are intended to take on NULL values. If any of the attributes in your relations need to allow NULLs, circle them. You should not worry about the real-world interpretation of this database design, just follow the procedure for translating to relations. Note: There are multiple correct answers based on the different translation schemes for subclasses. 2

StaffMember( ) TA( ) SecLeader( ) Class( ) Worked( ) Student( ) TookInfo( ) 2. Authorization (8 points) Consider the following two tables: Employee(ID, deptnum, salary) Department(deptNum, type) // ID is key // deptnum is key Is it possible to authorize a user U to delete employees in departments of type sales, but not delete any other employees? (Assume the SQL standard, not Oracle s implementation.) Circle one: YES NO If you circled YES, show a sequence of one or more SQL commands to grant this authorization to user U. If you circled NO, briefly explain why it is not possible. 3

3. Constraints (12 points, 6 per part) Consider a table Dancers(name,gender) containing a list of dancers; name is a key. (a) Write a SQL General Assertion stating that table Dancers contains the same number of males as females. (b) There are two distinct reasons the assertion from part (a) cannot be implemented as an attribute- or tuple-based CHECK constraint on table Dancers. What are the reasons? (Assume the SQL standard for constraints, not Oracle s implementation.) 4

4. Dependencies and Triggers (10 points, 5 each part) (a) Consider a table R(A; B; C) and suppose we want to enforce the functional dependency A! B on R using triggers. For each of the following five operations, if we need to create a trigger on this operation in order to enforce our functional dependency, circle the operation. If we don t need a trigger on this operation, cross it out. insert on R delete on R update of A on R update of B on R update of C on R (b) Now suppose we want to enforce the multivalued dependency A! B on R using triggers. For each of the following five operations, if we need to create a trigger on this operation in order to enforce our multivalued dependency, circle the operation. If we don t need a trigger on this operation, cross it out. insert on R delete on R update of A on R update of B on R update of C on R : (Ungraded scratch space) 5

5. Triggers (8 points) Consider a simple one-attribute table R(A) where A has type integer, and the following two triggers: create trigger T1 after insert on R for each row update R set A = A + 1 create trigger T2 after insert on R update R set A = A + 1 Assume that table R begins empty. (a) (4 points) We will create trigger T1 or trigger T2 but not both. Describe the simplest initial database modification you can come up with for which the final state of table R after trigger execution is different using trigger T1 than using trigger T2. You do not need to write the database modification statement in SQL, just specify the inserted, deleted, and/or updated tuples. (b) (2 points) What is the final state of table R with your initial modifications from part (a) and trigger T1? (c) (2 points) What is the final state of table R with your initial modifications from part (a) and trigger T2? 6

6. Transactions (18 points, 6 each part) Consider a table Bid(itemID,price). There are initially two tuples in Bid with values (i1,10) and (i2,20). Consider the following two concurrently executing transactions: T1: begin transaction; S1: update Bid set price = price + 5; S2: insert into Bid values (i3,30); commit; T2: begin transaction; S3: select sum(price) as p1 from Bid; S4: select max(price) as p2 from Bid; commit; In all parts of the problem transaction T1 executes with isolation level serializable. You may assume both transactions successfully commit, and the individual statements S1, S2, S3,andS4 within the transactions each execute atomically. (a) If transaction T2 also executes with isolation level serializable, what are the possible pairs of values p1 and p2 returned by T2? Please carefully indicate all possible pairs. (b) If transaction T2 executes with isolation level read committed, what are the possible pairs of values p1 and p2 returned by T2? Please carefully indicate all possible pairs. (c) If transaction T2 executes with isolation level read uncommitted, what are the possible pairs of values p1 and p2 returned by T2? Please carefully indicate all possible pairs. 7

7. Object-Relational SQL (5 points) Consider the following type definitions in SQL-99: create type PersonType (name NameType, address AddrType, birthdate string) create type NameType (lastname string, firstname string) create type AddrType (street string, city string, zip char(5)) Let us say that two tuples P1 and P2 of type PersonType denote the same person if and only if all components are the same: P1.name.lastName = P2.name.lastName and P1.name.firstName = P2.name.firstName and P1.address.street = P2.address.street and P1.address.city = P2.address.city and P1.address.zip = P2.address.zip and P1.birthdate = P2.birthdate Suppose we want to be able to always test equality of two tuples P1 and P2 of type PersonType by writing P1 = P2, instead of using the long conjunction above. What sequence of commands achieves this goal? Do not worry about precise syntax. 8

8. Temporal Relational Algebra (8 points) Consider a temporal relation Visits(student,TA,time), which records information about students visiting TAs during office hours. Attribute time is the special timestamp attribute of our temporal relational model. A student may visit different TAs, and may visit a single TA multiple times. Because the special time attribute contains sets of intervals as discussed in class, attribute pair <student,ta> forms a key for this relation. Write an expression in temporal relational algebra that returns all students who have spent a total of at least 30 hours visiting TAs. 9. OLAP and Views (18 points) Consider the following table containing enrollment information for students in courses: Took(studentID,year,dept,course,units) Assume the following two queries are asked frequently over this data: Q1: select year,dept,sum(units) Q2: select dept,course,sum(units) from Took from Took group by year, dept group by dept, course (a) (8 points) You are allowed to create one materialized view V over table Took to help answer both queries Q1 and Q2 efficiently in a data warehousing environment. Assume table Took is extremely large. Using your materialized view should substantially speed up the execution of both queries. Define the view using regular SQL view syntax: create materialized view V as... 9

(b) (4 points) Rewrite queries Q1 and Q2 into equivalent queries that use your materialized view V from part (a) instead of table Took. (c) (6 points) Now suppose you have available the special table CUBE(Took), where the aggregation operator incorporated into the CUBE is sum. Rewrite queries Q1 and Q2 into equivalent queries that use CUBE(Took) instead of Took. Write the queries so their execution is expected to be as efficient as possible over CUBE(Took). 10

10. Data Streams (10 points, 5 per part) Suppose your AuctionBase project were implemented using a Data Stream Management System (DSMS) instead of a Database Management System (DBMS). Specifically, consider the following two streams: create stream Items(itemID,sellPrice) create stream Bids(itemID,bidPrice) In these very simplified streams, an element on the Items stream indicates a new auction item and the price for which it sells automatically; itemid is a key for this stream. An element on the Bids stream indicates a bid for a particular item. You may assume bids arrive in strictly increasing price order for each item, and if a bid meets or exceeds the sell price for an item then there are no later bids for that item. (a) Consider the following query using the CQL language introduced in class for continuous queries over streams and relations: select Istream(I.itemID) from Items I [Range 1 Hour], Bids B [Rows 1] where I.itemID = B.itemID and B.bidPrice >= I.sellPrice In one sentence or less, state what this query produces. (b) Now consider the following query, also in the CQL language: select itemid, avg(bidprice) from Bids [Partition By itemid Rows 2] group by itemid The following elements have arrived on the Bids stream, in the following order: (i2,14) (i1,4) (i3,7) (i1,6) (i1,8) (i3,12) (i3,14) (i2,20) What is the current result of the query? 11

11. Recursion (8 points) Consider a table R(A) containing positive integers with no duplicates, and the following query in SQL-99 (allowing nonlinear recursion). with recursive Mystery(X,Y) as (select A as X, A as Y from R) union (select m1.x, m2.y from Mystery m1, Mystery m2 where m2.x = m1.y + 1) select max(y-x)+1 from Mystery In one sentence or less, state what this query returns. 12