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

Similar documents
Exam. Question: Total Points: Score:

Examination paper for TDT4145 Data Modelling and Database Systems

CSE344 Final Exam Winter 2017

Midterm 2: CS186, Spring 2015

CS145 Midterm Examination

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

Fundamentals of Database Systems

Homework 3: Relational Database Design Theory (100 points)

CSE 344 Final Examination

Final Examination Computer Science 420 Dr. St. John Lehman College City University of New York 21 May 2002

Database Management

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

Exam II Computer Programming 420 Dr. St. John Lehman College City University of New York 20 November 2001

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

Sample Exam for CSE 480 (2017) KEY

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

Functional Dependencies CS 1270

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

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

Sample Exam for CSE 480 (2016)

6 February 2014 CSE-3421M Test #1 w/ answers p. 1 of 14. CSE-3421M Test #1. Design

Part II: Using FD Theory to do Database Design

A7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

Database Management Systems Paper Solution

CS 327E Lecture 2. Shirley Cohen. January 27, 2016

ETH Zurich Spring Semester Systems Group Lecturer(s): Gustavo Alonso, Ce Zhang Date: August 19, Exam. Questions

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

Desired properties of decompositions

CS186 Final Exam Spring 2016

Lecture 04: SQL. Wednesday, October 4, 2006

The University of British Columbia

CSE 444 Midterm Test

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

Solutions to Final Examination

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

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

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

MATH 1075 Final Exam

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,

CSE 444 Midterm Exam

The University of Nottingham

The Relational Data Model

COMP302. Database Systems

CSE 344 Final Examination

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

CS 461: Database Systems. Final Review. Julia Stoyanovich

Database Systems. Basics of the Relational Data Model

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

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

Midterm Exam (Version B) CS 122A Spring 2017

The exam is open book; any written materials may be used, as well as on-line or

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

Database Management

QUIZ 1 REVIEW SESSION DATABASE MANAGEMENT SYSTEMS

Exam (Version B) for CSE 480 (2018) KEY

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

DBS 2006: 1 st week. DBS 2006: Plan. DB Life-Cycle: Requirement analysis. Data modelling: Conceptual Design. Logical Schema Design

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

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

SCHEMA REFINEMENT AND NORMAL FORMS

CSE 444, Winter 2011, Midterm Examination 9 February 2011

Draw A Relational Schema And Diagram The Functional Dependencies In The Relation >>>CLICK HERE<<<

4. SQL - the Relational Database Language Standard 4.3 Data Manipulation Language (DML)

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

Database Management Systems (Classroom Practice Booklet Solutions)

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

Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010

COSC Dr. Ramon Lawrence. Emp Relation

CSE 444 Homework 1 Relational Algebra, Heap Files, and Buffer Manager. Name: Question Points Score Total: 50

Introduction to Databases CSE 414. Lecture 2: Data Models

EECS-3421a: Test #2 Queries

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

Lecture 2: Introduction to SQL

Final Review. Zaki Malik November 20, 2008

CS 564 Final Exam Fall 2015 Answers

Lecture 11 - Chapter 8 Relational Database Design Part 1

EE221 Databases Practicals Manual

CS 564 Midterm Review

Lecture 04: SQL. Monday, April 2, 2007

CSE 414 Final Examination

Midterm Exam #1 Version A CS 122A Winter 2017

CS 2316 Exam 3. Practice. Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score.

Homework 6. Question Points Score Query Optimization 20 Functional Dependencies 20 Decompositions 30 Normal Forms 30 Total: 100

3 February 2011 CSE-3421M Test #1 p. 1 of 14. CSE-3421M Test #1. Design

Exam. Question: Total Points: Score:

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

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

Exam code: Exam name: Database Fundamentals. Version 16.0

SAMPLE FINAL EXAM SPRING/2H SESSION 2017

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

Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

Relational Database Design (II)

Exam (Version B) for CSE 480 (2018)

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

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

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

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

Normalization. Anomalies Functional Dependencies Closures Key Computation Projecting Relations BCNF Reconstructing Information Other Normal Forms

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

CSE-3421M Test #2. Queries

Transcription:

252-0834-00L Information Systems for Engineers Final exam ETH Zurich, Autumn Semester 2017 Friday 09.02.2018 First name: Last name: Legi number: Signature: You can fill out the above fields immediately, but do not open the exam before you are explicitly told so by the exam staff. Please fill in your first and last name using only block capital letters. It is your responsibility that your name and legi number are clearly legible. You have 90 minutes for the exam. There is no penalty for incorrect answers. Answers must be given in blue or black pen. Pencils, red pens, and green pens are not allowed. If you wish to change your answer, clearly strike out your previous solution, and write the new solution separately. Problem Points Score 1 6 2 3 3 2 4 2 5 5 6 4 7 6 8 24 9 11 10 7 11 12 12 9 13 5 14 2 15 8 Total: 106 1

Information Systems for Engineers - Final exam - Page 2 of 15 Friday, 09.02.2018 1. You are given the following relations: Students(legi, first_name, last_name) Results(legi, grade) You can refer to them as S and R, respectively. For each of the SQL statements below, write down a corresponding relational algebra expression: (a) 1 SELECT legi 2 FROM Results 3 WHERE grade >= 5.00; (b) 1 SELECT grade, COUNT(*) AS grade_count 2 FROM Results 3 GROUP BY grade; (c) 1 SELECT first_name, last_name, grade 2 FROM ((SELECT * FROM Results (3) 3 WHERE grade < 4.00) 4 INNER JOIN Students 5 ON Results.legi = Students.legi); 2. Mark all correct statements: (3) All partial functions are also functions. True False All functions are also partial functions. True False All partial functions are also relations. True False All relations are also partial functions. True False All relations are also functions. True False All functions are also relations. True False 3. If given a set of 4 partial functions with identical support that contains 2 attributes, in how many ways can we draw a corresponding table?

Information Systems for Engineers - Final exam - Page 3 of 15 Friday, 09.02.2018 4. For the following table of rivers, write down the corresponding set of partial functions, using the same syntax used in the lectures and exercise sessions. id name length 0 Tiber 406 1 Vistula 1047 2 Nile 6853 5. For each of the following descriptions of data fields, mark the most appropriate and efficient SQL data type for storing it that satisfies its precision requirements. (a) IATA airport codes (unique 3-character identifiers). CHAR(3) VARCHAR(3) TINYTEXT (b) Number of products sold of a certain type. FLOAT INT NUMERIC(7,2) (c) Your birthday. TIME DATE DATETIME (d) Prices of an online webshop. FLOAT INT NUMERIC(7,2) (e) When an order to an online shop was made. TIME DATE DATETIME

Information Systems for Engineers - Final exam - Page 4 of 15 Friday, 09.02.2018 6. For the table of rivers presented in Question 4, write down a corresponding SQL CREATE TABLE (4) statement using a fitting name and appropriate data types. id is the only key for the relation. No fields are allowed to be NULL. 7. You are given the following mathematical definition of a relation. (6) {R P(S V) ( t R, support(t) = { country, product line, product, margin } t.country S t.product line S t.product S t.margin R {null}) ( t, s R, t.country = s.country t.product line = s.product line t.product = s.product t = s)} Write down a corresponding SQL CREATE TABLE statement.

Information Systems for Engineers - Final exam - Page 5 of 15 Friday, 09.02.2018 8. For this question we consider tables that satisfy the following schemas: Customers(id:integer, name:string, age:integer) Products(id:integer, name:string, price:decimal) Orders(customer id:integer, product id:integer, time:datetime) Primary keys are underlined. customer id and product id are foreign keys to the Customers and Products tables, respectively. For each of the following statements, write down (i.) a corresponding relational algebra expression and (ii.) a corresponding SQL query. Time constants should be on the form 09:12:34, date constants should be on the form 2018-02-09, and datetime constants should be on the form 2018-02-09T09:12:34. (a) The name and price of all products cheaper than 20.00 CHF. i. Write down a relational algebra expression that returns the desired result. ii. Write down an SQL query that returns the desired result. (b) All orders placed before noon on New Year s day, 2017. i. Write down a relational algebra expression that returns the desired result. ii. Write down an SQL query that returns the desired result.

Information Systems for Engineers - Final exam - Page 6 of 15 Friday, 09.02.2018 (c) For each product that has been ordered at least once, return its ID and how many times it has been ordered. i. Write down a relational algebra expression that returns the desired result. ii. Write down an SQL query that returns the desired result. (d) All orders made by customers over the age of 60. i. Write down a relational algebra expression that returns the desired result. (3) ii. Write down an SQL query that returns the desired result. (3) (e) For each customer who has made at least one order, return their name and the price of the most expensive product that they bought. i. Write down a relational algebra expression that returns the desired result. (3) ii. Write down an SQL query that returns the desired result. (3)

Information Systems for Engineers - Final exam - Page 7 of 15 Friday, 09.02.2018 9. Consider a relation R(A, B, C, D, E). Consider also its decomposition into the relations R 1 (A, B, C), R 2 (B, C, D) and R 3 (C, D, E). We are now investigating whether or not this decomposition is lossless, assuming various sets of functional dependencies. (a) Fill in the starting Chase algorithm tableau for the above relation and decomposition. This table is to be used as the starting point for each one of the parts (b) through (e). Assignments (b), (c), (d) and (e) are separate and independent from each other. (b) Apply the Chase algorithm for the functional dependencies B A and A E, in this order. Fill in the updated tableau for each step of the algorithm below each corresponding functional dependency. Mark whether the decomposition is lossless or lossy. B A A E Lossless Lossy (c) Apply the Chase algorithm for the functional dependencies D B and C A, in this order. Fill in the updated tableau for each step of the algorithm below each corresponding functional dependency. Mark whether the decomposition is lossless or lossy. D B C A Lossless Lossy

Information Systems for Engineers - Final exam - Page 8 of 15 Friday, 09.02.2018 (d) Apply the Chase algorithm for the functional dependencies C E, D A and B D, (3) in this order. Fill in the updated tableau for each step of the algorithm below each corresponding functional dependency. Mark whether the decomposition is lossless or lossy. C E D A B D Lossless Lossy (e) Apply the Chase algorithm for the functional dependencies CD A, D E and A B, (3) in this order. Fill in the updated tableau for each step of the algorithm below each corresponding functional dependency. Mark whether the decomposition is lossless or lossy. CD A D E A B Lossless Lossy 10. Consider a relation R(A, B, C, D, E). For each of the following sets of functional dependencies, compute the closure of the set of attributes on the left of each functional dependency, then mark whether the set of functional dependencies is in BCNF or not. (a) A E In BCNF BD C Not in BCNF (b) A B B C C D D A In BCNF Not in BCNF (c) CD AB In BCNF AE CB Not in BCNF

Information Systems for Engineers - Final exam - Page 9 of 15 Friday, 09.02.2018 (d) A E E B B CD CD A In BCNF Not in BCNF AB E (e) DE C In BCNF C A Not in BCNF B A 11. Consider a relation R(A, B, C, D, E) with functional dependencies BC D and E A. Find a decomposition of this relation that is in Boyce-Codd Normal Form (BCNF) by solving all of the parts below, using the algorithm covered in the book, lectures and exercise sessions. (a) Using the given functional dependencies, show that the relation R is not in BCNF. (b) Based on your result from part (a), decompose R to two relations R 1 and R 2. State their attributes. R 1 ( ) R 2 ( ) (c) Show that one of the new relations from part (b) is in BCNF, while the other is not. You do not need to execute the functional dependency projection algorithm exhaustively. Still, you should show how the relevant functional dependencies are projected, rendering the new relations to be in BCNF or not. (3) (d) Decompose the relation from part (c) that is not in BCNF to R 3 and R 4. State their attributes. R 3 ( ) R 4 ( )

Information Systems for Engineers- Final exam - Page 10 of 15 Friday, 09.02.2018 (e) Show that both R 3 and R 4 from part (d) are in BCNF. You do not need to execute the (3) functional dependency projection algorithm exhaustively. Still, you should show how the relevant functional dependencies are projected, rendering the new relations to be in BCNF. (f) Based on your answers above, write down the final solution. 12. For this question we will determine if each of the schedules below are serializable. We use the following notation: r 2 (A) means that transaction 2 reads from location A; w 1 (B) means that transaction 1 writes to location B; etc. (a) The table below has been populated with the following schedule: r 4 (B), r 4 (A), w 1 (A), r 3 (A), w 3 (A), r 2 (A), w 3 (B), w 4 (A) Draw arrows between cells to mark each write-after-read, read-after-write and write-afterwrite dependency, then mark if the schedule is serializable or not. If you wish, you can use the diagram on the right to reach a conclusion. 1 2 3 4 r(b) r(a) w(a) r(a) w(a) r(a) w(b) w(a) 1 2 3 4 Serializable. Not serializable.

Information Systems for Engineers- Final exam - Page 11 of 15 Friday, 09.02.2018 (b) For the following schedule, fill in the table below, draw arrows to indicate sequential dependencies, then mark whether the schedule is serialiable or not: r 1 (C), r 2 (C), r 3 (A), r 4 (B), r 3 (B), w 3 (B), w 2 (C), r 1 (B), w 1 (B), w 4 (B) 1 2 3 4 1 2 3 4 Serializable. Not serializable. (c) For the following schedule, fill in the table below, draw arrows to indicate sequential dependencies, then mark whether the schedule is serialiable or not: r 4 (A), w 4 (A), r 1 (C), w 1 (C), r 2 (B), w 2 (B), r 2 (A), w 3 (A), w 3 (B), w 3 (C) 1 2 3 4 1 2 3 4 Serializable. Not serializable.

Information Systems for Engineers- Final exam - Page 12 of 15 Friday, 09.02.2018 (d) For the following schedule, fill in the table below, draw arrows to indicate sequential dependencies, then mark whether the schedule is serialiable or not: w 2 (C), r 1 (B), r 1 (A), r 4 (C), w 2 (B), w 3 (A), r 4 (A), r 3 (B) 1 2 3 4 1 2 3 4 Serializable. Not serializable. (e) For the following schedule, fill in the table below, draw arrows to indicate sequential dependencies, then mark whether the schedule is serialiable or not: r 3 (A), r 1 (A), w 2 (B), r 1 (B), w 3 (A), r 3 (B), w 3 (B), w 1 (A) 1 2 3 1 2 3 4 Serializable. Not serializable.

Information Systems for Engineers- Final exam - Page 13 of 15 Friday, 09.02.2018 13. You are given the following fact table: Country Indicator type Indicator name Indicator value Indicator year Liechtenstein Economic GDP 4087 2005 Liechtenstein Economic GDP growth rate 4.8 2005 Liechtenstein Economic GDP per capita 117279.2 2005 Liechtenstein Infrastructure Mobile-cellular subscriptions 79.2 2005 Liechtenstein Infrastructure Individuals using the Internet 63.4 2005 Liechtenstein Economic GDP 5678 2010 Liechtenstein Economic GDP growth rate 7.4 2010 Liechtenstein Economic GDP per capita 156533.4 2010 Liechtenstein Infrastructure Mobile-cellular subscriptions 98.3 2010 Liechtenstein Infrastructure Individuals using the Internet 80.0 2010 Liechtenstein Economic GDP 6361 2017 Liechtenstein Economic GDP growth rate 1.4 2017 Liechtenstein Economic GDP per capita 169491.8 2017 Liechtenstein Infrastructure Mobile-cellular subscriptions 108.8 2017 Liechtenstein Infrastructure Individuals using the Internet 96.6 2017 Switzerland Economic GDP 407543 2005 Switzerland Economic GDP growth rate 3.0 2005 Switzerland Economic GDP per capita 55009.4 2005 Switzerland Infrastructure Mobile-cellular subscriptions 92.2 2005 Switzerland Infrastructure Individuals using the Internet 70.1 2005 Switzerland Economic GDP 581209 2010 Switzerland Economic GDP growth rate 3.0 2010 Switzerland Economic GDP per capita 74223.4 2010 Switzerland Infrastructure Mobile-cellular subscriptions 123.2 2010 Switzerland Infrastructure Individuals using the Internet 83.9 2010 Switzerland Economic GDP 670790 2017 Switzerland Economic GDP growth rate 0.8 2017 Switzerland Economic GDP per capita 80831.1 2017 Switzerland Infrastructure Mobile-cellular subscriptions 142.0 2017 Switzerland Infrastructure Individuals using the Internet 88.0 2017 USA Economic GDP 13093726 2005 USA Economic GDP growth rate 3.3 2005 USA Economic GDP per capita 44214.7 2005 USA Infrastructure Mobile-cellular subscriptions 68.3 2005 USA Infrastructure Individuals using the Internet 68.0 2005 USA Economic GDP 14964371 2010 USA Economic GDP growth rate 2.5 2010 USA Economic GDP per capita 48291.5 2010 USA Infrastructure Mobile-cellular subscriptions 91.3 2010 USA Infrastructure Individuals using the Internet 71.7 2010 USA Economic GDP 18036648 2017 USA Economic GDP growth rate 2.6 2017 USA Economic GDP per capita 56053.8 2017 USA Infrastructure Mobile-cellular subscriptions 117.6 2017 USA Infrastructure Individuals using the Internet 74.6 2017

Information Systems for Engineers- Final exam - Page 14 of 15 Friday, 09.02.2018 Based on the fact table on the previous page, the following pivot table was created: Country Indicator name GDP GDP growth rate GDP per capita Liechtenstein 5678 7.4 156533.4 Switzerland 581209 3.0 74223.4 USA 14964371 2.5 48291.5 Total 15551258 12.9 140594.1 How was the above pivot table display built from the fact table? For each column in the fact table, state whether, in order to produce the above display, the column acts as: a slicer dimension; as a dicer dimension with an aggregation; as a dicer dimension without any aggregation; or whether it contains the fact values (measure). If it is a slicer dimension, you also need to specify which dimension value the data cube is sliced on. (a) Country: Dicer without aggregation Measure Slicer on: Dicer with aggregation (b) Indicator type: Dicer without aggregation Measure Slicer on: Dicer with aggregation (c) Indicator name: Dicer without aggregation Measure Slicer on: Dicer with aggregation (d) Indicator value: Dicer without aggregation Measure Slicer on: Dicer with aggregation (e) Indicator year: Dicer without aggregation Measure Slicer on: Dicer with aggregation 14. Assuming that you wrote an SQL query to produce the above pivot table, which of the following keywords could you have used for this purpose? Your query should produce exactly the values shown on the table. Check all that apply. ROLLUP CUBE GROUPING SETS

Information Systems for Engineers- Final exam - Page 15 of 15 Friday, 09.02.2018 15. Based on the fact table (we no longer consider the pivot table generated in Question 13), the following SQL query was written: 1 SELECT indicator_year, country, AVG(indicator_value) 2 FROM fact_table 3 WHERE indicator_name = "Individuals using the Internet" AND indicator_year > 2005 4 GROUP BY ROLLUP(indicator_year, country) 5 ORDER BY AVG(indicator_value) DESC Answer the following questions: (a) How many tuples would be returned if you executed the above query? (b) How many of the tuples returned by the query will include None/NULL values? How many tuples would be returned if you executed the above query? (c) Which tuple would be returned first if you executed the above query? (Select one answer) (2017, Liechtenstein, 96.60) (2010, Switzerland, 83.90) (None, Switzerland, 98.70) (None, None, 82.47) (d) Which tuple would be returned last if you executed the above query? (Select one answer) (2010, Liechtenstein, 80.00) (None, USA, 71.50) (2010, None, 78.53) (2010, USA, 71.70) (e) Assuming that the keyword ROLLUP is substituted for the keyword CUBE, how many of the tuples returned by the updated query will include None/NULL values?