Quiz 3: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354



Similar documents
Databases -Normalization III. (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31

Design of Relational Database Schemas

Relational Normalization Theory (supplemental material)

Theory behind Normalization & DB Design. Satisfiability: Does an FD hold? Lecture 12

Lecture Notes on Database Normalization

Relational Database Design

Schema Refinement and Normalization

Schema Design and Normal Forms Sid Name Level Rating Wage Hours

Database Design and Normalization

CS143 Notes: Normalization Theory

Normalization of database model. Pazmany Peter Catholic University 2005 Zoltan Fodroczi

COSC344 Database Theory and Applications. Lecture 9 Normalisation. COSC344 Lecture 9 1

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

Database Design and Normal Forms

Chapter 10. Functional Dependencies and Normalization for Relational Databases

Chapter 10. Functional Dependencies and Normalization for Relational Databases. Copyright 2007 Ramez Elmasri and Shamkant B.

Design Theory for Relational Databases: Functional Dependencies and Normalization

Schema Refinement, Functional Dependencies, Normalization

normalisation Goals: Suppose we have a db scheme: is it good? define precise notions of the qualities of a relational database scheme

Introduction Decomposition Simple Synthesis Bernstein Synthesis and Beyond. 6. Normalization. Stéphane Bressan. January 28, 2015

Functional Dependencies and Normalization

Objectives of Database Design Functional Dependencies 1st Normal Form Decomposition Boyce-Codd Normal Form 3rd Normal Form Multivalue Dependencies

Why Is This Important? Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) Example (Contd.)

Introduction to Database Systems. Normalization

Database Design and Normalization

Theory of Relational Database Design and Normalization

Database Management Systems. Redundancy and Other Problems. Redundancy

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 5: Normalization II; Database design case studies. September 26, 2005

Chapter 7: Relational Database Design

Functional Dependencies and Finding a Minimal Cover

Graham Kemp (telephone , room 6475 EDIT) The examiner will visit the exam room at 15:00 and 17:00.

Advanced Relational Database Design

Limitations of DB Design Processes

Database Constraints and Design

Relational Database Design Theory

Chapter 7: Relational Database Design

CSCI-GA Database Systems Lecture 7: Schema Refinement and Normalization

Relational Database Design: FD s & BCNF

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

Relational Normalization: Contents. Relational Database Design: Rationale. Relational Database Design. Motivation

Chapter 8. Database Design II: Relational Normalization Theory

Week 11: Normal Forms. Logical Database Design. Normal Forms and Normalization. Examples of Redundancy

Chapter 10 Functional Dependencies and Normalization for Relational Databases

DATABASE NORMALIZATION

How To Find Out What A Key Is In A Database Engine

Limitations of E-R Designs. Relational Normalization Theory. Redundancy and Other Problems. Redundancy. Anomalies. Example

The class slides, your notes, and the sample problem that we worked in class may be helpful for reference.

Boyce-Codd Normal Form

Functional Dependencies

Normalization. CIS 331: Introduction to Database Systems

Normalization. Normalization. Normalization. Data Redundancy

6.830 Lecture PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization

Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina

Announcements. SQL is hot! Facebook. Goal. Database Design Process. IT420: Database Management and Organization. Normalization (Chapter 3)

RELATIONAL DATABASE DESIGN

Database Management System

Theory of Relational Database Design and Normalization

Functional Dependency and Normalization for Relational Databases

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen

A Web-Based Environment for Learning Normalization of Relational Database Schemata

An Algorithmic Approach to Database Normalization

Lecture 2 Normalization

3. Database Design Functional Dependency Introduction Value in design Initial state Aims

Normalization in Database Design

TYPICAL QUESTIONS & ANSWERS

Unique column combinations

Database Systems Concepts, Languages and Architectures

The University of British Columbia

Normal forms and normalization

Normalization for Relational DBs

SQL DDL. DBS Database Systems Designing Relational Databases. Inclusion Constraints. Key Constraints

Objectives, outcomes, and key concepts. Objectives: give an overview of the normal forms and their benefits and problems.

CSE-3421: Exercises. with answers

Database Sample Examination

Introduction to Database Systems. Chapter 4 Normal Forms in the Relational Model. Chapter 4 Normal Forms

Homework Margin Purchases. Dr. Patrick Toche

Normalization Theory for XML

3.2 The Factor Theorem and The Remainder Theorem

User Manual. for the. Database Normalizer. application. Elmar Jürgens

Normalisation. Why normalise? To improve (simplify) database design in order to. Avoid update problems Avoid redundancy Simplify update operations

Conditional-Functional-Dependencies Discovery

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS

C# Cname Ccity.. P1# Date1 Qnt1 P2# Date2 P9# Date9 1 Codd London Martin Paris Deen London

Investors G u i d e Investors Guide 2011

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

DBMS. Normalization. Module Title?

Quiz 2: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354

DATABASE DESIGN: NORMALIZATION NOTE & EXERCISES (Up to 3NF)

Normalisation 1. Chapter 4.1 V4.0. Napier University

Chapter 8 Integers 8.1 Addition and Subtraction

Department of Computer Science 2015/16

Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.

Math 312 Homework 1 Solutions

Transcription:

Quiz 3: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354 1. [10] Show that each of the following are not valid rules about FD s by giving a small example relations that satisfy the given FD s (following the if ) but not the FD that allegedly follows (after the then ). a. (3) If A->B then B->A If attribute A represented Social Security Number and B represented a person s name, then we would assume A->B but B->A would not be valid because there may be many people with the same name and different Social Security Numbers. A B 1 2 2 2 b. (3) If AB->C and A->C, then B->C Let attribute A represent Social Security Number, B represent gender and C represent name. Surely Social Security Number and gender can uniquely identify a person s name (i.e. AB C). A Social Security Number can also uniquely identify a person s name (i.e. A C). However, gender does not uniquely determine a name (i.e. B C is not valid) A B C 1 1 1 2 1 2 c. (4) If AB->C, then A->C or B->C Let attribute A represent latitude and B represent longitude. Together, both attributes can uniquely determine C, a point on the world map (i.e. AB->C). However, neither A nor B can uniquely identify a point (i.e. A->C and B->C are not valid). A B C 1 1 1 2 1 2 1 2 3

2. [10] Suppose we have relation R(A,B,C,D,E), with some set of FD s, and we wish to project those FD s onto relation S(A,B,C). Give the FD s that hold in S if the FD s for R are: a. AB->D, AC->E, BC->D, D->A, and E->B. We need to compute the closures of all subsets of {ABC}, although there is no need to think about the empty set or the set of all three attributes. Here are the calculations for the remaining six sets: {A}+=A {B}+=B {C}+=C {AB}+=ABD {AC}+=ABCDE {BC}+=ABCDE We ignore D and E, so a basis for the resulting functional dependencies for ABC is: AC->B and BC->A.

3. [10] Let R(A,B,C,D,E)be decomposed into relations with the following three sets of attributes: {A,B,C}, {B,C,D}, and {A,C,E}. For the following sets of FD s, use the chase test to tell whether the decomposition of R is lossless. If it is not lossless, give an example of an instance of R that returns more than R when projected onto the decomposed relations and rejoined. A->D, D->E, and B->D This is the initial tableau: a b c d 1 e 1 a 1 b c d e 1 a b 1 c d 1 e This is the final tableau after applying FDs A D, D E and B D. a 1 b c d e a b 1 c d e Since there is an unsubscripted row, the decomposition for R is lossless for this set of FDs.

4. [10] Consider a relation Stocks(B, O, I, S, Q, D), whose attributes may be thought of informally as broker, office (of the broker), investor, stock, quantity (of the stock owned by the investor), and dividend (of the stock). Let the set of FD s for Stocks be S->D, I->B, IS->Q, and B->O. (2) What are all the keys for Stocks IS is the only key for the Stocks relation. (3) Verify that the given FD s are their own minimal basis. The first step to verify that the given FDs are their own minimal basis is to check {S + } = {S } {I + } = {I} {IS + } = {ISDBO } {B + } = {B + } The second step to verify that the given FDs are their own minimal basis is to check to see if any of the left sides of an FD can have one or more attributes removed without losing the dependencies. However, this is not the case for the one FD that contains two attributes on the left side. Thus, the given set of FDs has been verified to be the minimal basis. a. (5) Use the 3NF synthesis algorithm to find a lossless-join, dependencypreserving decomposition of R into 3NF relations. Are any of the relations not in BCNF? Since the only key is IS, the given set of FDs has some dependencies that violate 3NF. We also know that the given set of FDs is a minimal basis. Thus the decomposed relations are SD, IB, ISQ and BO. Since the relation ISQ contains a key, we do not need to add an additional relation. The final set of decomposed relations is SD, IB, ISQ and BO.

5. [10] For each of the following relations schemas and dependencies. a. R(A,B,C,D,E) with MVD s A->>B and AB->>C and FD s A->D and AB->E Do the following: i. (4) Find all the 4NF violations. From the FDs A D and AB E, we can deduce that the only key is ABC. The MVDs A B, AB C and the derived MVDs A D and AB E all violate 4NF. ii. (6) Decompose the relations into a collection of relation schemas in 4NF. We must separate out the attributes of these dependencies, first decomposing into AB and ACDE. However, there is still a 4NF violation in the latter from the MVD A D because A is not a superkey. Thus we further decompose ACDE into relations AD and ACE. There are no more 4NF violations for the three decomposed relations so we are done. The final set of relations is AB, AD and ACE

6. [10] Use the chase test to tell whether the following dependencies hold in a relations R(A, B, C, D, E) with the dependencies A->>BC, B->D, and C->>E. a. (4) A->>D Our starting tableau is: a b c d 2 e Applying MVD A BC we get: a b c d 2 e 1 a b 1 c 1 d 2 e Applying FD B D we get: 1 a b 1 c 1 d e Applying MVD C E we get: 1 a b 1 c 1 d e a b 1 c 1 d e 1 Since a row of all unsubscripted attributes exists, then the MVD A the relation. D holds in

(6) A->E Our starting tableau is: a b 2 c 2 d 2 e 2 Applying MVD A BC we get: a b 2 c 2 d 2 e 2 a b 1 c 1 d 2 e 2 Applying FD B D we get: a b 2 c 2 d 1 e 2 a b 1 c 1 d 1 e 2 Applying MVD C E we get: a b 2 c 2 d 1 e 2 a b 1 c 1 d 1 e 2 a b 1 c 1 d 1 e 2 a b 2 c 2 d 1 e 2 Using the chase test, it appears that the FD A E does not hold in the relation.