CSE 344 Midterm. November 9, 2011, 9:30am - 10:20am. Question Points Score Total: 100

Similar documents
CSE 344 Midterm. November 9, 2011, 9:30am - 10:20am. Question Points Score Total: 100

CSE 344 Midterm. Wednesday, February 19, 2014, 14:30-15:20. Question Points Score Total: 100

CSE 344 Midterm. Monday, Nov 4, 2013, 9:30-10:20. Question Points Score Total: 100

CSE 344 Midterm. Monday, November 9th, 2015, 9:30-10:20. Question Points Score Total: 70

CSE 344 Midterm. Wednesday, February 19, 2014, 14:30-15:20. Question Points Score Total: 100

CSE 344 Midterm. Monday, November 9th, 2015, 9:30-10:20. Question Points Score Total: 70

CSE 344 Midterm. Friday, February 8, 2013, 9:30-10:20. Question Points Score Total: 100

CSE 414 Midterm. Friday, April 29, 2016, 1:30-2:20. Question Points Score Total: 100

CSE 344 Final Examination

CSE344 Midterm Exam Fall 2016

McGill April 2009 Final Examination Database Systems COMP 421

CSE 344 Midterm. Monday, February 6, 2012, 9:30-10:20. This is a closed book exam. You have 50. Please write your answers in the space provided.

CSE344 Midterm Exam Winter 2017

CSE 444 Final Exam. August 21, Question 1 / 15. Question 2 / 25. Question 3 / 25. Question 4 / 15. Question 5 / 20.

CSE 444 Final Exam. December 17, Question 1 / 24. Question 2 / 20. Question 3 / 16. Question 4 / 16. Question 5 / 16.

CS145 Midterm Examination

CSE414 Midterm Exam Spring 2018

CSE 414 Midterm. April 28, Name: Question Points Score Total 101. Do not open the test until instructed to do so.

CSE 344 Final Exam. March 17, Question 1 / 10. Question 2 / 30. Question 3 / 18. Question 4 / 24. Question 5 / 21.

Computer Science 304

CS145 Midterm Examination

CS145 Midterm Examination

Introduction to Database Systems CSE 414

CSE 344 Midterm Exam

CSEP 514 Midterm. Tuesday, Feb. 7, 2017, 5-6:20pm. Question Points Score Total: 150

CSE 344 Midterm. Wednesday, Oct. 31st, 2018, 1:30-2:20. Question Points Score Total: 100

Fall, 2004 CIS 550. Database and Information Systems Midterm Solutions

CSE 344 Midterm. Wednesday, Nov. 1st, 2017, 1:30-2:20. Question Points Score Total: 100

CSE 344 Final Examination

10/24/12. What We Have Learned So Far. XML Outline. Where We are Going Next. XML vs Relational. What is XML? Introduction to Data Management CSE 344

Introduction to Database Systems CSE 414

EXAM Databases (DIT620/TDA355/TDA356/TDA357)

CSE-6490B Final Exam

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams

Midterm Exam #2 (Version A) CS 122A Winter 2017

XML, DTD, and XPath. Announcements. From HTML to XML (extensible Markup Language) CPS 116 Introduction to Database Systems. Midterm has been graded

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

University of California, Berkeley. CS 186 Introduction to Databases, Spring 2014, Prof. Dan Olteanu MIDTERM

CSE 444 Final Exam 2 nd Midterm

Querying XML. COSC 304 Introduction to Database Systems. XML Querying. Example DTD. Example XML Document. Path Descriptions in XPath

CS145 Introduction. About CS145 Relational Model, Schemas, SQL Semistructured Model, XML

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

CSE 444, Winter 2011, Final Examination. 17 March 2011

CS 564 Final Exam Fall 2015 Answers

CSCI-6421 Final Exam York University Fall Term 2004

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

CSE344 Final Exam Winter 2017

Math 355: Linear Algebra: Midterm 1 Colin Carroll June 25, 2011

XML. Solutions to Practice Exercises

EXAMINATIONS 2013 MID-YEAR SWEN 432 ADVANCED DATABASE DESIGN AND IMPLEMENTATION

10.3 Answer: 10.5 Answer:

CSCI 585 Database Systems Prof. Dennis McLeod. Sample Midterm Exam

CSE 414 Database Systems section 10: Final Review. Joseph Xu 6/6/2013

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

Midterm 1: CS186, Spring I. Storage: Disk, Files, Buffers [11 points] SOLUTION. cs186-

Marker s feedback version

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

CIS 550 Fall Final Examination. December 13, Name: Penn ID:

CISC437/637 Database Systems Final Exam

Introduction to Data Management CSE 344. Lecture 14: Relational Calculus

CSE 344 Midterm Nov 1st, 2017, 1:30-2:20

University of California, Berkeley. (2 points for each row; 1 point given if part of the change in the row was correct)

Introduction to Data Management CSE 344. Lecture 1: Introduction

Introduction to Database S ystems Systems CSE 444 Lecture 1 Introduction CSE Summer

XPath and XQuery. Introduction to Databases CompSci 316 Fall 2018

6.893 Database Systems: Fall Quiz 2 THIS IS AN OPEN BOOK, OPEN NOTES QUIZ. NO PHONES, NO LAPTOPS, NO PDAS, ETC. Do not write in the boxes below

Introduction to Data Management CSE 344

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

Storing XML in a RDBMS Approaches 1. Use generic db schema, [Florescu, Kossman 1999] 2. Use DTD to derive db schema [Shanmugasundaram, et al.

Part V. Relational XQuery-Processing. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2007/08 297

CPSC 310: Database Systems / CSPC 603: Database Systems and Applications Exam 2 November 16, 2005

Relational Algebra. Study Chapter Comp 521 Files and Databases Fall

XML. Semi-structured data (SSD) SSD Graphs. SSD Examples. Schemas for SSD. More flexible data model than the relational model.

Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course:

CISC437/637 Database Systems Final Exam

CSE 344 Final Examination

CSE 414 Final Examination

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

CSE 123: Computer Networks Fall Quarter, 2013 MIDTERM EXAM

Put your initials on the top of every page, in case the pages become separated.

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

CSE wi Final Exam Sample Solution

Computer Science 597A Fall 2008 First Take-home Exam Out: 4:20PM Monday November 10, 2008 Due: 3:00PM SHARP Wednesday, November 12, 2008

Introduction to Data Management CSE 344. Lecture 2: Data Models

Querying XML Data. Querying XML has two components. Selecting data. Construct output, or transform data

CSE 344 Midterm Exam

Semistructured Data and XML

2(Y/8K) * (1 + log15(y/(8k*16)) I/Os

Introduction to Database Systems. Fundamental Concepts

CS 186, Fall 1999 Midterm 2 Professor Hawthorn

CS157a Fall 2018 Sec3 Home Page/Syllabus

MaanavaN.Com DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING QUESTION BANK

Fundamentals of Database Systems

CSCI3030U Database Models

CSE 344 MAY 7 TH EXAM REVIEW

CSE 562 Final Exam Solutions

XML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9

CSE 344 JANUARY 5 TH INTRO TO THE RELATIONAL DATABASE

Midterm Exam #1 Version B CS 122A Winter 2017

INF 315E Introduction to Databases School of Information Fall 2015

Transcription:

CSE 344 Midterm November 9, 2011, 9:30am - 10:20am Name: Question Points Score 1 40 2 40 3 20 Total: 100 This exam is open book and open notes but NO laptops or other portable devices. You have 50 minutes; budget time carefully. Please read all questions carefully before answering them. Some questions are easier, others harder. Plan to answer all questions, do not get stuck on one question. If you have no idea how to answer a question, write your thoughts about the question for partial credit. Good luck! 1

1. SQL and Physical Tuning (40 points) You are in charge of managing the program committee for an important conference. The following database stores information about papers submitted to the conference (table Paper), reviewers on the program committee (table Reviewer), and the assignment of reviewers to papers (table Reviews). Each reviewer on the program committee will have to review a set of papers. Each paper will be reviewed by some subset of reviewers. Paper(pid, title) Reviewer(rid, name) Reviews(rid, pid) pid is a unique paper identifier and the primary key of the Paper table. rid is a unique reviewer identifier and the primary key of the Reviewer table. Reviews.rid is a foreign key that references Reviewer.rid. Reviews.pid is a foreign key that references Paper.pid. A reviewer is assigned zero or more papers. A paper is assigned zero or more reviewers. (a) (15 points) Write a SQL query that finds all papers with fewer than three reviewers assigned to them. The output of the query should be a list of paper titles. The result should include papers without any reviewers assigned to them. Answer (write a SQL query): SELECT P.title FROM Paper P LEFT OUTER JOIN Reviews X ON P.pid = X.pid GROUP BY P.pid, P.title HAVING count(*) < 3 Page 2

Paper(pid, title) Reviewer(rid, name) Reviews(rid, pid) (b) (15 points) Write a SQL query that finds the reviewers with the most papers assigned to them. There can be more than one such reviewer. The output of the query should be a list of reviewer names. A reviewer should be listed if no other reviewer has strictly more papers to review. Answer (write a SQL query): SELECT R.name FROM Reviewer R, Reviews X1 WHERE R.rid = X1.rid GROUP BY R.rid, R.name HAVING count(*) >= ALL ( SELECT count(*) FROM Reviews X2 GROUP BY X2.rid ) Page 3

Paper(pid, title) Reviewer(rid, name) Reviews(rid, pid) (c) (10 points) Suggest 2 indexes that would speed-up your queries from the previous questions. Explain why you are selecting these indexes. Answer (Suggest and justify the selection of two indexes): Since the above queries join the three tables together in different ways, a natural choice is to index the primary keys and foreign keys. One possible solution is to index Paper.pid and Reviewer.rid. Another option is to index Reviews.pid and Reviews.rid. The indexes do not need to be clustered since the queries are not doing any range selections on these attributes. [Other solutions are possible]. Page 4

2. Relational Algebra, Calculus, and Datalog (40 points) Consider the following database schema: Neighbors(name1,name2,duration) Colleagues(name1,name2,duration) (a) (15 points) Write a Relational Algebra Plan for the SQL query below. Your answer can be in the form of an expression or a tree, whichever you prefer: SELECT DISTINCT C1.name1, C2.name2 FROM Colleagues C1, Neighbors N, Colleagues C2 WHERE C1.name2 = N.name1 AND N.name2 = C2.name1 AND C1.duration < 10 AND C2.duration < 10 AND N.duration > 100 Answer (write a Relational Algebra Plan): C1.name1, C2.name2 C1.duration < 10 and C2.duration < 10 and N.duration > 100 N.name2=C2.name1 C1.name2=N.name1 Colleagues C1 Neighbors N Colleagues C2 Page 5

Neighbors(name1,name2,duration) Colleagues(name1,name2,duration) (b) (15 points) Write a Datalog query that returns all neighbors who do not have any colleagues in common. Answer (write a Datalog query): NonAnswers(n1,n2) :- Neighbors(n1,n2, ), Colleagues(n1,c, ), Colleagues(n2,c, ) A(n1,n2) :- Neighbors(n1,n2, ) NOT NonAnswers(n1,n2) Page 6

Neighbors(name1,name2,duration) Colleagues(name1,name2,duration) (c) (10 points) Indicate if the following relational calculus queries are correct or not (true or false). Note: This is not meant to be a tricky question. Errors, if any, should be reasonably obvious. You do NOT need to correct wrong queries: Answer (true or false) Find all people who have a neighbor that has a colleague. A(x) = y. z.neighbors(x, y, ) Colleagues(y, z, ) TRUE/FALSE Find all people who have only neighbors that are also their colleagues. A(x) = Neighbors(x,, ) ( y.neighbors(x, y, ) Colleagues(x, y, )) TRUE/FALSE Find all people who have only neighbors that have at least one colleague. A(x) = N eighbors(x,, ) ( y.n eighbors(x, y, ) z.colleagues(y, z, )) TRUE/FALSE TRUE FALSE. The correct answer is A(x) = Neighbors(x,, ) ( y.neighbors(x, y, ) Colleagues(x, y, )) TRUE Page 7

3. XML, XPath, and XQuery (20 points) Consider the following DTD, which describes the schema for a database containing a list of players. The rank of a player indicates whether the player is a Beginner or an Advanced player. The score is the total number of points accumulated by the player. <!DOCTYPE game [ <!ELEMENT game (player*)> <!ELEMENT player (rank,score)> <!ATTLIST player name CDATA #REQUIRED > <!ELEMENT rank (#PCDATA )> <!ELEMENT score (#PCDATA )> ]> (a) (20 points) Write an XQuery expression that reformats a valid XML document, as per the above DTD, into one that matches the following DTD. In this new format, we want to group Beginner players into one category and Advanced players into another category: <!DOCTYPE game [ <!ELEMENT game (category*)> <!ELEMENT category (rank, player*)> <!ELEMENT player (name, score) > <!ELEMENT rank (#PCDATA )> <!ELEMENT name (#PCDATA )> <!ELEMENT score (#PCDATA )> ]> Answer (write an XQuery): <game> { for $d in doc("game.xml")/game for $r in distinct-values($d/player/rank/text()) return <category> <rank> {$r} </rank> { for $p in $d/player[rank=$r] return <player> <name> { string($p/@name) } </name> <score>{ $p/score/text() } </score> </player> } </category> } </game> Page 8