Midterm Exam. Name: CSE232A, Winter February 21, Brief Directions:

Similar documents
CSE344 Midterm Exam Winter 2017

Exam 1. March 20th, CS525 - Midterm Exam Solutions

CSE Midterm - Spring 2017 Solutions

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

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

CS 564 Final Exam Fall 2015 Answers

Lecture Query evaluation. Combining operators. Logical query optimization. By Marina Barsky Winter 2016, University of Toronto

CS 245 Midterm Exam Solution Winter 2015

CSE344 Midterm Exam Fall 2016

Final Exam CSE232, Spring 97, Solutions

Homework 1: RA, SQL and B+-Trees (due September 24 th, 2014, 2:30pm, in class hard-copy please)

CMSC 424 Database design Lecture 18 Query optimization. Mihai Pop

Homework 1: RA, SQL and B+-Trees (due Feb 7, 2017, 9:30am, in class hard-copy please)

Introduction to Query Processing and Query Optimization Techniques. Copyright 2011 Ramez Elmasri and Shamkant Navathe

Database Applications (15-415)

The appendix contains information about the Classic Models database. Place your answers on the examination paper and any additional paper used.

Relational Model and Relational Algebra A Short Review Class Notes - CS582-01

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

Contents Contents Introduction Basic Steps in Query Processing Introduction Transformation of Relational Expressions...

Name: Problem 1 Consider the following two transactions: T0: read(a); read(b); if (A = 0) then B = B + 1; write(b);

Final Exam CSE232, Spring 97

CS 245 Midterm Exam Winter 2014

CSE 530 Midterm Exam

CS145 Midterm Examination

Relational Model, Relational Algebra, and SQL

bè ëfind all countries C and the sum S of all of C's city populations, provided S is at least 10,000,000", SUMèPopulationè GROUP BY Co Name HAVING SUM

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

Administration Naive DBMS CMPT 454 Topics. John Edgar 2

Relational Model & Algebra. Announcements (Tue. Sep. 3) Relational data model. CompSci 316 Introduction to Database Systems

EXAMINATION PAPER. Exam in: INF-2700 Database Systems Date: Thursday Time: Kl 15:00-19:00 Place: Åsgårdveien 9. Approved aids: None

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

CSE 530 Midterm Exam

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

Database Management Systems Written Examination

Query Processing and Optimization *

Database Management Systems (CS 601) Assignments

CS425 Midterm Exam Summer C 2012

Midterm Review. Winter Lecture 13

Plan for today. Query Processing/Optimization. Parsing. A query s trip through the DBMS. Validation. Logical plan

Algorithms for Query Processing and Optimization. 0. Introduction to Query Processing (1)

COURSE OVERVIEW THE RELATIONAL MODEL. CS121: Relational Databases Fall 2017 Lecture 1

CS-245 Database System Principles

CS 222/122C Fall 2017, Final Exam. Sample solutions

COSC-4411(M) Midterm #1

COURSE OVERVIEW THE RELATIONAL MODEL. CS121: Introduction to Relational Database Systems Fall 2016 Lecture 1

Faloutsos - Pavlo CMU SCS /615

Overview. Carnegie Mellon Univ. School of Computer Science /615 - DB Applications. Concepts - reminder. History

2.2.2.Relational Database concept

Databases. Jörg Endrullis. VU University Amsterdam

Relational Algebra BASIC OPERATIONS DATABASE SYSTEMS AND CONCEPTS, CSCI 3030U, UOIT, COURSE INSTRUCTOR: JAREK SZLICHTA

Chapter 14 Query Optimization

Exam. Question: Total Points: Score:

Chapter 14 Query Optimization

Chapter 14 Query Optimization

CSE548, AMS542: Analysis of Algorithms, Fall 2012 Date: October 16. In-Class Midterm. ( 11:35 AM 12:50 PM : 75 Minutes )

Query Processing with Indexes. Announcements (February 24) Review. CPS 216 Advanced Database Systems

Database Technology Introduction. Heiko Paulheim

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

Overview of Query Processing and Optimization

More B-trees, Hash Tables, etc. CS157B Chris Pollett Feb 21, 2005.

Relational Model and Algebra. Introduction to Databases CompSci 316 Fall 2018

Advanced Databases. Lecture 4 - Query Optimization. Masood Niazi Torshiz Islamic Azad university- Mashhad Branch

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

Query Processing & Optimization

Relational Algebra and SQL. Basic Operations Algebra of Bags

Course No: 4411 Database Management Systems Fall 2008 Midterm exam

Relational Algebra. Algebra of Bags

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

CS 461: Database Systems. Final Review. Julia Stoyanovich

From SQL-query to result Have a look under the hood

Databases Relational algebra Lectures for mathematics students

Database Systems, CSCI Exam #2 Thursday November 4, 2010 at 2 pm

Chapter 3. Algorithms for Query Processing and Optimization

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2012

Query Optimization. Query Optimization. Optimization considerations. Example. Interaction of algorithm choice and tree arrangement.

University of Waterloo Midterm Examination Sample Solution

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

Query Processing and Advanced Queries. Query Optimization (4)

Relational Databases. Relational Databases. Extended Functional view of Information Manager. e.g. Schema & Example instance of student Relation

Basic operators: selection, projection, cross product, union, difference,

Lassonde School of Engineering Winter 2016 Term Course No: 4411 Database Management Systems

Chapter 12: Query Processing

NAME: March 4. and ask me. To pace yourself, you should allow on more than 1 minute/point. For

CS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13

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

Relational Query Languages

CSE 562 Midterm Solutions

CS2300: File Structures and Introduction to Database Systems

Integrity and Security

Practice midterm exam

Introduction to Database Systems CSE 444

CSE414 Midterm Exam Spring 2018

Query processing and optimization

ECE 2035 A Programming HW/SW Systems Spring problems, 5 pages Exam Three 13 April Your Name (please print clearly)

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)

Relational Model and Relational Algebra

The divide and conquer strategy has three basic parts. For a given problem of size n,

PROBLEM 1 : (And the winner is...(12 points)) Assume you are considering the implementation of a priority queue that will always give you the smallest

Final Exam Review Sheet INFO/CSE 100 Spring 2006

CSE 332, Spring 2010, Midterm Examination 30 April 2010

Transcription:

Midterm Exam CSE232A, Winter 2002 February 21, 2002 Name: Brief Directions: ² Write clearly: First, you don't want me to spend the whole week grading, do you? Second, it's good for you to write clearly! ² Open books, notes, even databases... ² Good luck! 1

1 B+ Trees (20 points) Consider a B+ tree where n = 4, i.e., the maximum number of keys in a node is 4 and the maximum number of pointers is 5 at internal nodes and 4 at leaf nodes. Assume that the B+ tree initially consists of a single node, which is both the root and the only leaf, that has the key 1. 1. 2pointsWhat is the minimum number of keys that may appear in a non-root internal node? 2. 2pointsWhat is the minimum number of keys that may appear in a non-root leaf node? 3. 8points 1 Consider the set of keys S = f1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13g. Write down a sequence of inserting the keys of S such that at the end the resulting B+ tree has 3 levels and is as empty as possible, i.e., as many nodes as possible have the minimum number of nodes. Provide the B+ tree snapshots that correspond to the points right after node splits. (Use the white space at the end of the page and the back side of this page.) 4. 8points 2 Consider the set of keys S 0 = f1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20g. Write down a sequence of inserting the keys of S 0 such that at the end the resulting B+ tree is as full as possible, i.e., as many nodes as possible have the maximum number of nodes. Provide the B+ tree snapshots that correspond to the points right after a node split. (Use the next blank page.) Remarks ² Be consistent in the way you split nodes. ² Assume that there are no duplicate nodes in the internal leaves. 2 Extensible Hash Index (10 points) Assume that each bucket of an extensible hash index can t exactly two records (each record is a pair of hash key and pointer). Consider the following records, with the corresponding hash key values. Key hash key a 0000 b 0001 c 0010 d 0011 e 0100 f 0110 g 1000 We insert the records in the order given above. Show the extensible hash index after all records have been inserted. 1 Maybetimeconsuming. 2 Maybetimeconsuming 2

3 Algebra (10 points) Consider the following two de nitions of the semijoin operator.<, which may or may not be equivalent. ² Direct (from page 255 of the textbook) The semijoin.< of relations R and S, writtenr.< S, is the bag of tuples t in R such that there is at least one tuple in S that agrees with t in all attributes that R and S have in common. ² Indirect Let us call a(r) the list of attributes of R. Then, it is where 1 stands for the natural join. R.< S = ¼ a(r) (R 1 S) 1. 5pointsAre the two de nition equivalent? Assume bag semantics for the algebra. If the answer is yes provide proof, showing that, given arbitrary R and S, ifatuplet appears k times in the result of R.< S according to the direct de nition, then the tuple t will appear k times in the result of R.< S according to the indirect de nition. If the answer is no, provide an example with an R table and an S table and show R.< S for the direct and the indirect de nition. 2. 5pointsConsider the indirect de nition of.<. Assume that the schema of P is P (A; B; C; D) and the schema of T is T (C; E). Prove the following, using the notation shown in the Appendix. ¼ A;B ¾ D=5^E=6 (P 1 T )=¼ A;B [(¼ A;B;C ¾ D=5 P ).< (¼ C ¾ E=6 T )] 4 Query Processing (32 points) Consider the relations Cust(CID; N ame; City), Order(OID; CID; Date), and LineItem(LID; OID; P roduct; Amount), where CID is a customer id and is a key for Cust, OID is an order id and is a key for Order, andlid is a line item id and is a key for LineItem. In addition the attribute CID of Order is a foreign key referring to the CID of Cust, thatis,for each CID c of Order there is exactly one tuple of Cust whose CID attribute is c. The OID of LineItem is a foreign key referring to the OID of Order. Assume the following statistics, where all numbers, except for product, correspond to millions. T (Cust)=1 V (Cust;CID)=1 V (Cust;Name)=0:5 T (Order) =20 V (Order; OID) =20 V (Order; CID) =1 T (LineItem) = 100 V (LineItem;LID) = 100 V (LineItem;OID)=20 V (LineItem; P roduct) = 1000 Consider the following SQL query, which returns the total amount for each product that \Jones" bought. 3

SELECT Product, SUM(Amount) AS Total FROM Cust, Order, LineItem WHERE Cust.CID = Order.CID AND Order.OID = LineItem.OID AND Cust.Name = 'Jones' GROUPBY Product 1. 5pointsWrite an algebra expression that uses two cartesian products, exactly one selection ¾ and the SUM Product;Amount7!Total operator and computes the SQL query. 2. 5pointsShow the series of transformations that transform the algebra expression of the previous question into an expression where the cartesian products have been replaced by joins and the selections are pushed as down (early) as possible. Assume that the equation ¾ R:A=S:A (R S) =R 1 R:A=S:A S is one of the transformation rules. 3. 5pointsProvide an additional (non-trivial) expression where the selections have been pushed as down (early) as possible, but the join order is di erent. No need to show the series of transformations that led you to this expression. 4. 10 points So far you must have provided 2 algebra expressions with di erent join orders. For each one of them provide an estimate of the size of its intermediate results. Also, provide an estimate of the size of the nal result. To save time, just put the size numbers next to the edges in the algebra expressions. 5. 7pointsAssume that you have got indices on all attributes. Consider the following simpli- cation of the query: SELECT Product, Amount FROM Cust, Order, LineItem WHERE Cust.CID = Order.CID AND Order.OID = LineItem.OID AND Cust.Name = 'Jones' Apply the INGRES algorithm to get a join order. Indicate which is the small relation hyperedge that you pick in each step of the algorithm and show the resulting plan. 4

A What will get you full points in proving equivalence of algebraic expressions Assume that the exercise is to prove that ¾ p^q (P 1 T )=(¾ p P ) 1 (¾ q T ) where p refers to attributes of P only and q refers to attributes of T only. The cleanest proofs are the ones where each step corresponds to application of one of the rules in the notes. In our example, it goes as follows: ¾ p^q (P 1 T )= ¾ p ¾ q (P 1 T )= ¾ p (P 1 ¾ q T )= (¾ p P ) 1 (¾ q T ) 5