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

Similar documents
Homework 3: Relational Database Design Theory (100 points)

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

Carnegie Mellon University Department of Computer Science /615 - Database Applications C. Faloutsos & A. Pavlo, Spring 2014.

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

Carnegie Mellon University Department of Computer Science /615 - Database Applications C. Faloutsos & A. Pavlo, Fall 2016

15-415/615 Homework 8, Page 2 of 11 Thu, 4/24/2014, 1:30pm

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

Carnegie Mellon University Department of Computer Science /615 - Database Applications C. Faloutsos & A. Pavlo, Fall 2015

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

Fundamentals of Database Systems

UNIT 3 DATABASE DESIGN

Functional Dependencies and Finding a Minimal Cover

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

Relational Database Design (II)

SCHEMA REFINEMENT AND NORMAL FORMS

Relational Database Design Theory. Introduction to Databases CompSci 316 Fall 2017

Lecture 6a Design Theory and Normalization 2/2

CMU SCS CMU SCS CMU SCS CMU SCS whole nothing but

Homework 2 (by Ao Zeng) Solutions Due: Friday Sept 28, 11:59pm

Homework 5 (by Tupac Shakur) Due: Monday Dec 3, 11:59pm

Database Management

CMU - SCS / Database Applications Spring 2013, C. Faloutsos Homework 1: E.R. + Formal Q.L. Deadline: 1:30pm on Tuesday, 2/5/2013

Homework 7. For your information: Graded out of 100 points; 2 questions total 5-10 hours for phase 1; hours for phase 2.

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

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Overview - detailed. Goal. Faloutsos & Pavlo CMU SCS /615

CSE 562 Database Systems

customer = (customer_id, _ customer_name, customer_street,

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

Carnegie Mellon University Department of Computer Science /615 - Database Applications C. Faloutsos & A. Pavlo, Spring 2014.

Database Systems. Basics of the Relational Data Model

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

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

Unit 3 : Relational Database Design

Homework 5 (by Tupac Shakur) Solutions Due: Monday Dec 3, 11:59pm

Chapter 8: Relational Database Design

CSIT5300: Advanced Database Systems

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

Normalization 03. CSE3421 notes

Databases Lecture 7. Timothy G. Griffin. Computer Laboratory University of Cambridge, UK. Databases, Lent 2009

Reminders - IMPORTANT:

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

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 10-2

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

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

Database Management

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

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

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

EECS-3421a: Test #2 Queries

Functional dependency theory

COSC Dr. Ramon Lawrence. Emp Relation

A7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

Schema Normalization. 30 th August Submitted By: Saurabh Singla Rahul Bhatnagar

Chapter 10. Normalization. Chapter Outline. Chapter Outline(contd.)

Schema Refinement & Normalization Theory 2. Week 15

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

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

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

Parallel development II 11/5/18

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

Database Management Systems Paper Solution

Functional Dependencies CS 1270

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

Chapter 10. Chapter Outline. Chapter Outline. Functional Dependencies and Normalization for Relational Databases

CS127 Homework #3. Due: October 11th, :59 P.M. Consider the following set of functional dependencies, F, for the schema R(A, B, C, D, E)

COMP7640 Assignment 2

Review: Attribute closure

Relational Design: Characteristics of Well-designed DB

Midterm Exam (Version B) CS 122A Spring 2017

The University of British Columbia

Informal Design Guidelines for Relational Databases

Homework 6 (by Sivaprasad Sudhir) Solutions Due: Monday Nov 27, 11:59pm

CS x265 Exam 3 Spring ALL questions 5 points, except question 11 I will not use a source other than my brain on this exam: (please sign)

CSE 444 Midterm Test

Chapter 6: Relational Database Design

Database Constraints and Design

Schema And Draw The Dependency Diagram

CS 461: Database Systems. Final Review. Julia Stoyanovich

Relational Database design. Slides By: Shree Jaswal

The Relational Model and Normalization

Functional Dependencies and. Databases. 1 Informal Design Guidelines for Relational Databases. 4 General Normal Form Definitions (For Multiple Keys)

Lecture 11 - Chapter 8 Relational Database Design Part 1

Introduction to Database Design, fall 2011 IT University of Copenhagen. Normalization. Rasmus Pagh

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

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

Chapter 14. Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies

Final Review. Zaki Malik November 20, 2008

Examination paper for TDT4145 Data Modelling and Database Systems

Examination examples

UNIT -III. Two Marks. The main goal of normalization is to reduce redundant data. Normalization is based on functional dependencies.

Midterm 2: CS186, Spring 2015

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

Lecture #8 (Still More Relational Theory...!)

Administrivia Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications

Administrivia Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications

The Relational Data Model

Attach extra pages as needed. Write your name and ID on any extra page that you attach. Please, write neatly.

Midterm Exam #1 Version A CS 122A Winter 2017

V. Database Design CS448/ How to obtain a good relational database schema

Homework 1: Relational Algebra and SQL (due February 10 th, 2016, 4:00pm, in class hard-copy please)

Transcription:

Carnegie Mellon University Department of Computer Science 15-415/615- Database Applications C. Faloutsos & A. Pavlo, Spring 2015 Prepared by Vinay & Jiayu DUE DATE: Tuesday, 3/24/2015, 1:30pm Homework 6 IMPORTANT Deposit hard copy of your answers in class at 1:30pm on Tuesday, 3/24/2015. Separate answers, as usually, i.e., please solve each of the 4 questions on a separate page, and type the usual, full information, on each page: your name, Andrew ID, course #, Homework #, and Question #. Reminders Plagiarism: Homework may be discussed with other students, but all homework is to be completed individually. Typeset all of your answers whenever possible. Illegible handwriting may get no points, at the discretion of the graders. Late homeworks: please email late homeworks to all TAs with the subject line exactly 15-415 Homework Submission (HW 6) and the count of slip-days you are using. For your information: Graded out of 100 points; 4 questions total Rough time estimate: 6 hours (1-2 hours for each question) Revision : 2015/03/18 19:04 Question Points Score Query Optimization 20 Functional Dependencies 20 Decompositions 30 Normal Forms 30 Total: 100 1

15-415/615 Homework 6, Page 2 of 7 Tuesday, 3/24/2015, 1:30pm Question 1: Query Optimization..................... [20 points] For this problem we consider a movie reviewing database with following three tables: 1. Movies(title, imdb number, year), where the primary key is imdb number; 2. Reviewers(userid, username), where the primary key is userid; 3. Reviews(userid, imdb number, rating, comment), where the primary key is (userid, imdb number), userid is foreign key referencing Reviewers, and imdb number is foreign key referencing Movies. For these tables we know the following statistics: Movies consists of N 1 = 60, 000 tuples, there are: 40,000 distinct movie titles, 90 distinct years, 1925 2014 inclusive. Reviewers consists of N 2 = 50, 000 tuples, there are: 50,000 distinct userids, 50,000 distinct usernames Reviews consists of N 3 = 1, 300, 000 tuples, there are: 38,000 distinct userids, 33,000 distinct movie titles, 5 distinct ratings (i.e. 1, 2, 3, 4, and 5) without nulls. For the queries below, assume that there are no correlations between the columns of a table nor any prior knowledge about the data (i.e., assume uniform distribution). Estimate the number of resulting tuples for the query, and give the answer with fourth significant digit accuracy. We will accept either rounding half up or down, but no partial credit will be given. (a) [3 points] SELECT * FROM Movies WHERE year = 2001; (b) [4 points] SELECT * FROM Movies WHERE year = 1999 AND title = Fight Club (c) [4 points] SELECT * FROM Reviews WHERE rating > 3 (a) (b) (c) (d) [4 points] SELECT year, count(*) FROM Movies GROUP BY year (d) Question 1 continues...

15-415/615 Homework 6, Page 3 of 7 Tuesday, 3/24/2015, 1:30pm (e) [5 points] SELECT count(*) FROM Movies JOIN Reviews ON Movies.imdb number = Reviews.imdb number GROUP BY Movies.title (e) Homework 6 continues...

15-415/615 Homework 6, Page 4 of 7 Tuesday, 3/24/2015, 1:30pm Question 2: Functional Dependencies................ [20 points] 2.1 Consider the following legal instance of a relational schema S with attributes ABC: S A B C α 9 T α 16 F β 20 F Table 1: Legal instance of schema S for question 2.1 (a) Which of the following dependencies are violated by the instances of S in Table 1? i. [1 point] Yes No : A B is violated. ii. [1 point] Yes No : B A is violated. iii. [1 point] Yes No : C A is violated. iv. [1 point] Yes No : AC B is violated. v. [1 point] Yes No : B AC is violated. (b) [1 point] By only observing the instance of S in Table 1, can you identify the functional dependencies that hold on schema S? Yes No 2.2 For the next set of questions consider the relational schema r = {P, Q, R, S, T, U, V } and the set of functional dependencies FD: P Q (1) Q R (2) P S T RV (3) QT UR (4) S V (5) (a) [3 points] Which of the following is a minimum cover of the FD? (a) The given FD is a minimum cover. (b) {P Q, Q R, P S T, QT UR, S V } (c) {P Q, Q R, P T, Q U, S V } (d) {P Q, Q R, P S T, QT U, S V } (e) none of the above - the cover is (b) Yes/No: Which of the following functional dependencies can be deduced, from the above set of functional dependencies (Eq. (1)-(5))? Question 2 continues...

15-415/615 Homework 6, Page 5 of 7 Tuesday, 3/24/2015, 1:30pm i. [1 point] Yes No : P R ii. [2 points] Yes No : P S U iii. [2 points] Yes No : QS U iv. [2 points] Yes No : QST P (c) [2 points] True or False: The attribute closure {Q} + is {Q, R, T }. True False (d) [2 points] True or False: The attribute closure {P S} + is {P, Q, R, S, T, U, V }. True False Homework 6 continues...

15-415/615 Homework 6, Page 6 of 7 Tuesday, 3/24/2015, 1:30pm Question 3: Decompositions......................... [30 points] 3.1 For this set of questions, Consider the relation with attributes, S = {A, B, C, D, E, F }, Let the following functional dependencies F D be defined over the relation S: A D A E D C D F (a) [6 points] Provide the attribute closure of {AB}. (b) Identify whether the decomposition ABC, CDE, EF A is lossless and dependencypreserving? (c) Identify whether the decomposition ABCE, ADC, ADEF is lossless and dependency-preserving? 3.2 Consider the relation with attributes, A = {P, Q, R, S, T, U, V }. The following functional dependencies hold over A. RT P QS T R Q (a) Identify whether the decomposition QST, QR, P RSU V is lossless and dependencypreserving? (b) Identify whether the decomposition QST, QR, P RSUV, P RT is lossless and dependency-preserving? Homework 6 continues...

15-415/615 Homework 6, Page 7 of 7 Tuesday, 3/24/2015, 1:30pm Question 4: Normal Forms.......................... [30 points] Consider the relation with attributes, S = {A, B, C, D, E}. Let the following functional dependencies be defined over the relation S, A BC CD E B D E A (a) Identify whether this relationship in 3NF and/or BCNF? i. [2 points] Yes No : 3NF ii. [2 points] Yes No : BCNF (b) [5 points] Provide the projection of FDs for the subset of attributes {ABD} (c) [8 points] Give a BCNF decomposition of S that is lossless. (d) [3 points] Is your BCNF decomposition dependency preserving? True False Give a 3NF decomposition of S that is lossless and dependency pre- (e) [10 points] serving. End of Homework 6