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

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

Homework 5: Miscellanea (due April 26 th, 2013, 9:05am, in class hard-copy please)

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

Handout 3: Functional Dependencies and Normalization

Project Assignment 2 (due April 6 th, 2015, 4:00pm, in class hard-copy please)

Homework 7: Transactions, Logging and Recovery (due April 22nd, 2015, 4:00pm, in class hard-copy please)

Project Assignment 2 (due April 6 th, 2016, 4:00pm, in class hard-copy please)

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

Combining schemas. Problems: redundancy, hard to update, possible NULLs

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

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

Homework 2: E/R Models and More SQL (due February 17 th, 2016, 4:00pm, in class hard-copy please)

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

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

Homework 3: Relational Database Design Theory (100 points)

Exercise 9: Normal Forms

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

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

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

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

FUNCTIONAL DEPENDENCIES

Database Systems. Basics of the Relational Data Model

CSE 562 Database Systems

Functional dependency theory

Part II: Using FD Theory to do Database Design

Chapter 7: Relational Database Design

Functional Dependencies CS 1270

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

Schema And Draw The Dependency Diagram

Homework 4: Query Processing, Query Optimization (due March 21 st, 2016, 4:00pm, in class hard-copy please)

CS145 Midterm Examination

Case Study: Lufthansa Cargo Database

Homework 3: Map-Reduce, Frequent Itemsets, LSH, Streams (due March 16 th, 9:30am in class hard-copy please)

Relational Design Theory. Relational Design Theory. Example. Example. A badly designed schema can result in several anomalies.

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

Schema Refinement: Dependencies and Normal Forms

Babu Banarasi Das National Institute of Technology and Management

Design Theory for Relational Databases

SCHEMA REFINEMENT AND NORMAL FORMS

Functional Dependencies and Finding a Minimal Cover

Redundancy:Dependencies between attributes within a relation cause redundancy.

UNIT 3 DATABASE DESIGN

DATABASE MANAGEMENT SYSTEMS

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

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

customer = (customer_id, _ customer_name, customer_street,

COSC Dr. Ramon Lawrence. Emp Relation

Unit 3 : Relational Database Design

Schema Refinement: Dependencies and Normal Forms

Chapter 8: Relational Database Design

Database Design Principles

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

Fundamentals of Database Systems

Database Normalization

Database Systems CSE Comprehensive Exam Spring 2005

Relational Database Design (II)

Schema Refinement & Normalization Theory 2. Week 15

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

Review: Attribute closure

Database Constraints and Design

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

Informal Design Guidelines for Relational Databases

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

MaanavaN.Com DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING QUESTION BANK

Schema Refinement: Dependencies and Normal Forms

Homework 2: Query Processing/Optimization, Transactions/Recovery (due February 16th, 2017, 9:30am, in class hard-copy please)

Chapter 6: Relational Database Design

Lecture 5 Design Theory and Normalization

CS352 Lecture - Conceptual Relational Database Design

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

CS352 Lecture - Conceptual Relational Database Design

COMP7640 Assignment 2

Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

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

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

Section 1: Redundancy Anomalies [10 points]

Desired properties of decompositions

Relational Design: Characteristics of Well-designed DB

Lecture 6a Design Theory and Normalization 2/2

CSIT5300: Advanced Database Systems

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

Functional Dependencies & Normalization for Relational DBs. Truong Tuan Anh CSE-HCMUT

Database Design Theory and Normalization. CS 377: Database Systems

Theory of Normal Forms Decomposition of Relations. Overview


Ryan Marcotte CS 475 (Advanced Topics in Databases) March 14, 2011

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

CSCI DBMS Spring 2017 Final Examination. Last Name: First Name: Student Id:

Midterm Exam (Version B) CS 122A Spring 2017

Normalisation. Normalisation. Normalisation

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

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

NORMAL FORMS. CS121: Relational Databases Fall 2017 Lecture 18

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

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

Presentation on Functional Dependencies CS x265

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

Homework 4: Clustering, Recommenders, Dim. Reduction, ML and Graph Mining (due November 19 th, 2014, 2:30pm, in class hard-copy please)

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

CSCI 5333 DBMS Spring 2018 Final Examination. Last Name: First Name: Student Id:

Transcription:

Virginia Tech. Computer Science CS 4604 Introduction to DBMS Spring 2015, Prakash Homework 6: FDs, NFs and XML (due April 15 th, 2015, 4:00pm, hard-copy in-class please) Reminders: a. Out of 100 points. Contains 5 pages. b. Rough time-estimates: ~5-7 hours. c. Please type your answers. Illegible handwriting may get no points, at the discretion of the grader. Only drawings may be hand-drawn, as long as they are neat and legible. d. There could be more than one correct answer. We shall accept them all. e. Whenever you are making an assumption, please state is clearly. f. Important: Unless otherwise mentioned, assume that you need to show your work e.g. if the question asks what are R s keys? we do not just want a list; we want a step-by-step explanation as well. g. Lead TA for this homework: Elaheh Raisi. Q1. FDs Definition [8 points] (Modified version of Exercise 19.6 in your textbook) Suppose that we have the following three tuples in a legal instance of relation schema S with three attributes ABC: A B C 1 X a 4 X b 5 Y a Q1.1 (5 points) Which of the following dependencies can you infer does not hold over schema S? (a) A B, (b) BC A, (c) B C, (d) B A, (e) C AB Q1.2 (3 points) Can you identify any functional dependencies that may hold over S? Q2. Inferring FDs [27 points] Consider the following relations and sets of functional dependencies that hold in those relations. For each sub-part, it is enough for you to list only completely non-trivial FDs with a single attribute on the right hand side. Note that candidate key means just key (i.e. both words are interchangeable). A candidate key (or simply key) should imply the entire relation and should be minimal. On the other hand, a superkey is any super-set of a candidate key. 1

Q2.1 R1(A, B, C, D) with FDs A C, C D, and D B. Q2.1.1 (3 points) What are all the non-trivial FDs that follow from the given FDs? Q2.1.2 (3 points) What are all the keys (i.e. candidate keys) of R1? Q2.1.3 (3 points) What are all the superkeys for R1? Q2.2 R2(A, B, C, D) with FDs AD C, C A, and D B. Q2.2.1 (3 points) What are all the non-trivial FDs that follow from the given FDs? Q2.2.2 (3 points) What are all the keys (i.e candidate keys) of R2? Q2.2.3 (3 points) What are all the superkeys for R2? Q2.3 R3(A, B, C, D, E) with FDs AB D, B E, C B, and DE C. Q2.3.1 (3 points) What are all the non-trivial FDs that follow from the given FDs? Q2.3.2 (3 points) What are all the keys (i.e. candidate keys) of R3? Q2.3.3 (3 points) What are all the superkeys for R3? Q3. Projection of FDs [26 points] Consider the the relation schema r = {P, Q, R, S, T, U, V} and the following FDs set: F = {PR S, P T, PT R, S U, ST V, TV S, QT V, V Q} Consider also the relational schemas: R1 (P, Q, R, S, T), R2 (Q, T, V), and R3 (S, T, U, V). Q3.1 (3x3=9 points) Compute the projection of the FD-set F on each of the three relations R1, R2 and R3. Only write down a minimal cover. Q3.2 (2x3=6 points) What are all the candidate keys (i.e. the keys) for each of the three relations R1, R2 and R3? Q3.3 (2x3=6 points) For each of the three relations, indicate if it is (A) BCNF and (B) 3NF. Explain your answer. Q3.4 (3 points) Decompose R3 into two relational schemas R31 and R32 so that they are in 3NF and the decomposition is lossless and dependency preserving. Show your work. Use the standard 3NF synthesis algorithm. 2

Q3.5 (2 points) Is it possible to decompose R3 into two schemas (say R3 and R3 ) such that both R3 and R3 are in BCNF and it is both lossless-join and dependencypreserving decomposition? Q4. Creating dependencies [8 points] A relation R(A, B, C) satisfies the functional dependencies A B and A C. Q4.1 (4 points) State another functional dependency that R must satisfy so these three functional dependencies (i.e., A B, A C and the new functional dependency) allow us to infer that R also B C. Your answer cannot contain B or C on the right hand side! Show your work. For the next two parts of this question, assume that the new functional dependency you stated in Q4.1 also holds in R. Again, show your work for the next two parts as well. Q4.2 (2 points) What are R's keys? Q4.3 (2x1=2 points) Is R in (A) BCNF and (C) 3NF? Q5. FDs in English language [24 points] Consider the following table, which stores customer-order information. CustomerOrderDB (CustomerNo, Name, Balance, CreditLimit, Ship-to-Address, OrderNo, OrderDate, DetailNo, ItemNo, QuantityOrdered, ItemExpireDate, DiscountRate, ItemPrice, ItemTax) Now consider the following constraints in English: Statement 1 Every customer has a unique customer number (CustomerNo). Other information for customer like Name, Balance and Credit Limit (CreditLimit) are kept. Statement 2 Statement 3 Statement 4 Every customer can have several ship-to-addresses. For every order we have HEADING information: order number (OrederNo), which is unique for every order. Order date (OrderDate) and Ship-to-address of customer. Customers might request several items in one order. So, the order details that are detail number (DetailNo), item number (ItemNo) and quantity ordered (QuantityOrdered) should be recorded. 3

Statement 5 Statement 6 Statement 7 Every Item has Item number (ItemNo), Item Expire Date (ItemExpireDate), Discount Rate (DiscountRate), Item Price (ItemPrice) and Item Tax (ItemTax). Discount Rate (DiscountRate) is computed based on the expiration date of Item (ItemExpireDate); the closer to the date of expiration; the higher discount will be applied. Item tax (ItemTax) is defined using discount rate (DiscountRate) and item price (ItemPrice). Tax on discounted price is different from the tax on items without discount. Clearly this is not a good relational design, as it contains redundancies and update, insertion and deletion anomalies. Hence we want to decompose it into a good schema. Q5.1 (7 points) List the functional dependencies for this relation that you can construct using the English description and also specifically mention the corresponding statement number(s) you used to formulate each FD. Note: some statement(s) might not result in a FD. Hint: You should get 6 FDs. Q5.2 (3 points) Rigorously prove (using Armstrong s axioms) that you can derive the FD: ItemExpireDate ItemPrice à ItemTax from the set of the FDs you found in Q5.1. Show your steps. Q5.3 (9 points) Is the above relation in BCNF using the FDs you found in Q5.1? If not, decompose it into a set of BCNF relations. Q5.4 (4 points) Is your resulting decomposition in Q5.3 dependency-preserving? If it is not dependency-preserving, explain your answer, and then decompose the original relation into a set of 3NF relations instead. Show your steps. Q6. XML [7 points] (Courtesy Widom and Ullman) This question is based on the XML "Vehicles" document below. <Vehicles> <Car manf="hyundai"> <Model>Azera</Model> 4

<Car manf="toyota"> <Model>Camry</Model> <Truck manf="toyota"> <Model>Tundra</Model> </Truck> <Car manf="hyundai"> <Model>Elantra</Model> <HorsePower>120</HorsePower> <Car manf="toyota"> <Model>Prius</Model> <HorsePower>120</HorsePower> </Vehicles> Q6.1 (3 points) Which of the following XPath expressions, when applied to the "Vehicles" document, does NOT produce a sequence of exactly three items? a) /Vehicles/Car[@manf="Toyota"]/HorsePower b) /Vehicles/*[HorsePower>200]/Model c) //*[@manf="toyota"]/@manf Justify your answer briefly (i.e. give the output of the query (queries) which do not produce a sequence of three items). Q6.2 (4 points) In a DTD that the "Vehicles" document satisfies, which of the following element declarations would you definitely NOT find? a) <!ELEMENT Vehicles (Car*, Truck+, Car*)> b) <!ELEMENT Vehicles (Car+, Truck*, Car)> c) <!ELEMENT Vehicles ((Car Truck)*)> d) <!ELEMENT Vehicles (Car*, Truck*, Car*, Truck*, Car*)> Again, just justify your choice(s) briefly (i.e. explain why you would not find your selected element declaration(s) in a DTD for Vehicles). 5