Examination examples

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

COMP7640 Assignment 2

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

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

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

CSE 562 Database Systems

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

More Normalization Algorithms. CS157A Chris Pollett Nov. 28, 2005.

A7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

DATABASE MANAGEMENT SYSTEMS

Database Management Systems Paper Solution

SCHEMA REFINEMENT AND NORMAL FORMS

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

COSC Dr. Ramon Lawrence. Emp Relation

Babu Banarasi Das National Institute of Technology and Management

COSC344 Database Theory and Applications. Lecture 5 SQL - Data Definition Language. COSC344 Lecture 5 1

CS411 Database Systems. 05: Relational Schema Design Ch , except and

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

Database Constraints and Design

QUIZ 1 REVIEW SESSION DATABASE MANAGEMENT SYSTEMS

Fundamentals of Database Systems

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

Relational Database Design (II)

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

EECS-3421a: Test #2 Queries

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

Lecture 11 - Chapter 8 Relational Database Design Part 1

CS 461: Database Systems. Final Review. Julia Stoyanovich

BCNF. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong BCNF

Database Design Theory and Normalization. CS 377: Database Systems

CS145 Midterm Examination

Database Management Systems (Classroom Practice Booklet Solutions)

BIRKBECK (University of London)

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

Mobile and Heterogeneous databases Distributed Database System Query Processing. A.R. Hurson Computer Science Missouri Science & Technology

Chapter 6 Part I The Relational Algebra and Calculus

The Relational Data Model

The University of British Columbia

Introduction to Databases Exam

Schema Refinement and Normal Forms

Chapter 8: Relational Database Design

Database Systems CSE Comprehensive Exam Spring 2005

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

SOLUTIONS TO THE FINAL EXAMINATION Introduction to Database Design Spring 2011

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Final Review. Zaki Malik November 20, 2008

Chapter 19 Query Optimization

CSE344 Final Exam Winter 2017

Slides by: Ms. Shree Jaswal

NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E)

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select,

Unit 3 : Relational Database Design

Chapter 6 The Relational Algebra and Calculus

CS2255 DATABASE MANAGEMENT SYSTEMS QUESTION BANK UNIT I

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

RELATIONAL ALGEBRA. CS 564- Fall ACKs: Dan Suciu, Jignesh Patel, AnHai Doan

Solutions to Final Examination

GUJARAT TECHNOLOGICAL UNIVERSITY

Chapter 3. Algorithms for Query Processing and Optimization

UNIVERSITY OF CALIFORNIA College of Engineering Department of EECS, Computer Science Division

Wentworth Institute of Technology COMP2670 Databases Spring 2016 Derbinsky. Physical Tuning. Lecture 12. Physical Tuning

Database Management Systems (Solutions for Vol 1_Classroom Practice Questions)

Examination paper for TDT4145 Data Modelling and Database Systems

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

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Midterm Exam (Version B) CS 122A Spring 2017

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

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

UNIVERSITY OF TORONTO MIDTERM TEST SUMMER 2017 CSC343H Introduction to Databases Instructor Tamanna Chhabra Duration 120 min No aids allowed

SQL STRUCTURED QUERY LANGUAGE

Exam. Question: Total Points: Score:

Wentworth Institute of Technology COMP570 Database Applications Fall 2014 Derbinsky. Physical Tuning. Lecture 10. Physical Tuning

NOTE: DO NOT REMOVE THIS EXAM PAPER FROM THE EXAM VENUE

NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E)

Solutions to Final Examination

Databases -Normalization I. (GF Royle, N Spadaccini ) Databases - Normalization I 1 / 24

CSIT5300: Advanced Database Systems

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

Functional Dependencies CS 1270

Database Management Systems,

Database Management Systems (CS 601) Assignments

Homework 3: Relational Database Design Theory (100 points)

Database Systems External Sorting and Query Optimization. A.R. Hurson 323 CS Building

1. (a) Explain the Transaction management in a database. (b) Discuss the Query Processor of Database system structure. [8+8]

Chapter 18 Strategies for Query Processing. We focus this discussion w.r.t RDBMS, however, they are applicable to OODBS.

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

CS403- Database Management Systems Solved Objective Midterm Papers For Preparation of Midterm Exam

Introduction to SQL. ECE 650 Systems Programming & Engineering Duke University, Spring 2018

This lecture. Databases -Normalization I. Repeating Data. Redundancy. This lecture introduces normal forms, decomposition and normalization.

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

The University of Nottingham

B.C.A DATA BASE MANAGEMENT SYSTEM MODULE SPECIFICATION SHEET. Course Outline

Lecture #16 (Physical DB Design)

Mahathma Gandhi University

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

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

CSE 544 Principles of Database Management Systems

8) A top-to-bottom relationship among the items in a database is established by a

DATABASE DESIGN II - 1DL400

Solutions. Updated of 7

Transcription:

Examination examples Databasteknik (5 hours) 1. Relational Algebra & SQL (4 pts total; 2 pts each). Part A Consider the relations R(A, B), and S(C, D). Of the following three equivalences between expressions of relational algebra, which are true? (a) π A,B (R S) =R (b) π A,B,D (R B=C S)=R ρ T (B,D) (S) (c) R ρ T (A,B) (S) =ρ T (A,B) (S ρ U(C,D) (R)) Part B Suppose we are given a relation Empls(employeeID, personnum, name, managerid) and want to find the ID s of all employees who do not manage any employee named Sandra. Here are two possible queries: I. SELECT managerid FROM Empls WHERE NOT EXISTS(SELECT * FROM Empls WHERE name = Sandra ); II. SELECT managerid FROM Empls WHERE NOT(employeeID = SOME(SELECT employeeid FROM Empls WHERE name = Sandra )); Which, if any, of the two queries will correctly get the desired set of employees? 2. Relational Database Design (6 pts total). Suppose we have a relation R(A, B, C, D, E) with the following set of functional dependencies: A B, C D, BD E, ande C. (a) (1 pt) Indicate which are the candidate keys for R. (b) (1.5 pts) Indicate which of the functional dependencies violate BCNF. (c) (1.5 pts) Indicate which of the functional dependencies violate 3NF. (d) (2 pts) Suppose we decompose R into several relations, one of which has schema ACE. What nontrivial functional dependencies hold for ACE? You need not mention a functional dependency if it follows from another that you mention by adding attributes to the left side, and you need not mention functional dependencies that have more than one attribute on the right.

3. Object-Oriented and Object-Relational Databases (4 pts total) a) What three kinds of user-definable database extensibility mechanisms available in an object-relational database system? b) Which of the above extensibility mechanisms are lacking or weak in a simple object-oriented database system (i.e. in an object store)? 4. Security and Integrity (4 pts total) a) How is authorization specified in modern relational databases? b) Why are views useful for authorization? c) When can a user transfer authorization rights to another user? d) What is domain constraints and what are they used for? 2

5. Query Optimization (4 pts total) a) What is selectivity and how is it used in cost-based query optimization? b) What is the worst case complexity of cost-based query optimization and how does one avoid this cost? c) Why does cost-based query optimization pay off despite its complexity? d) What is evaluation primitives? Give some examples of evaluation primitives. How are they used by a cost-based query optimizer? 6. Relational Algebra & SQL (6 pts total). Consider the following relations for keeping track of customers, products, and purchases: product(pid,pname,type,vendor,price) bought(cid,pid) customer(cid,cname,age,sex) Write the following queries in the relational algebra and in SQL: (a) (1+1 pts) Find the name and price of each product that has been purchased by at least one male customer. (b) (1+1 pts) Find the name of each customer that has not purchased a product whose type is computer. (c) (1+1 pts) Find the name and sex of each each supershopper a customer who has purchased all products costing more than 10000. 7. Security and Integrity (6 pts total, 2 each) (a) Why are views useful for authorization in modern relational databases? (b) How is referential integrity specified in modern relational databases? (c) What is domain constraints in the relational data model and what are they used for? 8. Query Optimization (6 pts total, 2 each) Given is the relational table SALARIES(SSN,AMOUNT) where SSN is key with ordered primary index and AMOUNT has an ordered secondary index. The table has 1000000 tuples. Each data block holds 100 tuples. We state the query SELECT SSN, AMOUNT FROM SALARIES ORDER BY AMOUNT DESCENDING (a) Outline the cheapest execution plan (using evaluation primitives) for evaluating the above query. 3

(b) Approximately how many blocks does the above plan access? Show calculations and assumptions. (c) Describe shortly the principles of cost-based query optimization. 9. Active Databases (6 pts total, 2 each) We have two tables EXPLOYEE(SSN, DNO, SALARY), key SSN DEPT(DNO, MGRSSN), key DNO SSN: Social security number DNO: Department number SALARY: Employee (incl. manager) salary MGRSSN: Social security number of department manager (a) Outline code of how to use active database facilities to maintain a master table of the sum of all salaries per department: SALSUM(DNO,SALSUM), key DNO (b) Assume a table maximizing the total salary budget for each department: BUDGET(DNO,TOTSAL), key DNO Outline code for using same kind of active database facilities to guarantee that no department ever has higher salaries than budgeted. (c) What extra functionality does an active relational database provide compared to a passive one? 10. ODBC (2 pts total, 1 each) (a) What is ODBC? (b) What is the difference between JDBC and ODBC? 11. Relational Algebra & SQL (7 pts total). Consider the following self-expanatory relational schema: Student(id: int, name: string, nation: string, age: int) Plays(id: int, sport: string) (a) (2 pts) Can you write a SQL query that is equivalent to the following one but does not use the keyword DISTINCT? If so, give the query. If not, explain why not. SELECT DISTINCT nation FROM student WHERE age > 25 (b) (2 pts) Can you write a SQL query that is equivalent to the following one but does not use a HAVING clause? If so, give the query. If not, explain why not. 4

SELECT sport FROM student, plays WHERE student.id = plays.id GROUP BY sport HAVING AVG(age) > 25 (c) (3 pts) The following question does not depend on the relational schema above. Consider the following SQL query: SELECT p.a1 FROM p, r1, r2 WHERE p.a1 = r1.a1 OR p.a1 = r2.a1 Under which conditions does this preceding query select values of p.a1 that are either in r1 or in r2? Be precise in your answer and careful to examine all cases. 12. Relational Database Design (5 pts total). Suppose we have a relation R(A, B, C, D, E) with functional dependencies F = {AB C, C E,E C, C D, AB E}. (a) (3pts) Find a dependency preserving, lossless join decomposition of R into 3NF. (b) (2pts) Is the decomposition {ABC, ADE, CE} dependency preserving with respect to F? Explain briefly. 13. Active Databases (6 pts total) a) What are the components of ECA in a relational database? (3 pts) b) What extra functionality does an active relational database provide compared to a passive one? (2 pts) c) Why is it often difficult to implement complex integrity constraints with triggers? (1 pt) 14. Object-Oriented Databases (6 pts total) a) What is pointer swizzling? (1 pt) b) What is an OID? (1 pt) c) What facilities are better supported in relational databases than in first generation objectoriented databases (object stores)? (4 pts) 15. Query Processing (4 pts total) A large company maintains a table of the effectiveness of their sales force: SALES(SSN, SALES) containing the SALES (in $) of each sales person identified with SSN, primary index on SSN and secondary index on SALES. There are 10000 sales persons and 100 tuples fit a disk block. The management need to regularly know the top ten sales performers and you are asked to design an application program to quickly get those stars. a) What query would your application use and how would it be called to get the answer quickly? (2 pts) 5

b) What is the optimal query execution plan? (1 pt) c) How many disk blocks are read? Motivate shortly. (1 pt) 16. Relational calculus (4 pts total) Express over relations PERSON(SSN, NAME, ADDRESS, PHONE) EMPLOYEE(SSN, SALARY, DEPT) the query below in domain calculus, and tuple calculus, respectively. SELECT NAME, SALARY FROM PERSON, EMPLOYEE WHERE SALARY>100000 AND PERSON.SSN = EMPLOYEE.SSN 6