CS430 Final March 14, 2005

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

COSC344 Database Theory and Applications. σ a= c (P) S. Lecture 4 Relational algebra. π A, P X Q. COSC344 Lecture 4 1

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

DATABASE MANAGEMENT SYSTEMS

Functional Dependencies and Normal Forms

CS 348 Introduction to Database Management Assignment 2

COSC Dr. Ramon Lawrence. Emp Relation

Sample Question Paper

Part 1 on Table Function

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

CS403- Database Management Systems Solved MCQS From Midterm Papers. CS403- Database Management Systems MIDTERM EXAMINATION - Spring 2010

Functional Dependencies and Normal Forms

Relational Model. CS 377: Database Systems

Relational Database design. Slides By: Shree Jaswal

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

CIS611 Lab Assignment 1 SS Chung

Database Design Theory and Normalization. CS 377: Database Systems

We shall represent a relation as a table with columns and rows. Each column of the table has a name, or attribute. Each row is called a tuple.

Functional Dependencies and Normalization for Relational Databases Design & Analysis of Database Systems

RELATIONAL DATA MODEL

ECE 650 Systems Programming & Engineering. Spring 2018

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

Dr. Anis Koubaa. Advanced Databases SE487. Prince Sultan University

Informal Design Guidelines for Relational Databases

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

Normalization in DBMS

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

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

Database Systems Relational Model. A.R. Hurson 323 CS Building

CS 377 Database Systems

Database Management Systems Paper Solution

Database Systems: An Application-Oriented Approach (Complete Version) Practice Problems and Solutions for Students

Chapter 3. Introducation to Relational Database 9/2/2014 CSC4341 1

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

Applied Databases. Sebastian Maneth. Lecture 5 ER Model, normal forms. University of Edinburgh - January 25 th, 2016

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

Database Technologies. Madalina CROITORU IUT Montpellier

Mapping ER Diagrams to. Relations (Cont d) Mapping ER Diagrams to. Exercise. Relations. Mapping ER Diagrams to Relations (Cont d) Exercise

COSC Assignment 2

From ER to Relational Model. Book Chapter 3 (part 2 )

PES Institute of Technology Bangalore South Campus (1 K.M before Electronic City,Bangalore ) Department of MCA. Solution Set - Test-II

To understand the concept of candidate and primary keys and their application in table creation.

Fundamentals of Database Systems

GUJARAT TECHNOLOGICAL UNIVERSITY

King Fahd University of Petroleum and Minerals

Overview Relational data model

Chapter 2: Intro to Relational Model

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

Relational Database Systems Part 01. Karine Reis Ferreira

Database Technology. Topic 2: Relational Databases and SQL. Olaf Hartig.

SQL STRUCTURED QUERY LANGUAGE

Relational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions.

UNIT 3 DATABASE DESIGN

L130 - DATABASE MANAGEMENT SYSTEMS LAB CYCLE-1 1) Create a table STUDENT with appropriate data types and perform the following queries.

The strategy for achieving a good design is to decompose a badly designed relation appropriately.

Chapter 14 Outline. Normalization for Relational Databases: Outline. Chapter 14: Basics of Functional Dependencies and

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

Objective. The goal is to review material covered in Chapters 1-5. Do the following questions from the book.

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

After completing this unit, you should be able to: Use inner joins to retrieve data from more than one table

Applied Databases. Sebastian Maneth. Lecture 5 ER Model, Normal Forms. University of Edinburgh - January 30 th, 2017

Database design process

Relational Algebra Part I. CS 377: Database Systems

Relational Databases Overview

The Relational Model

Conceptual Design. The Entity-Relationship (ER) Model

An Introduction to Structured Query Language

Database Management Systems,

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

The Relational Model 2. Week 3

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

Notes. CS 640 Relational Algebra Winter / 16. Notes. CS 640 Relational Algebra Winter / 16. Notes

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

Databases. Relational Model, Algebra and operations. How do we model and manipulate complex data structures inside a computer system? Until

Views. Lecture 15. Robb T. Koether. Fri, Feb 16, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) Views Fri, Feb 16, / 28

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

CS 338 Basic SQL Part II

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

Chapter 4. The Relational Model

Chapter 6: RELATIONAL DATA MODEL AND RELATIONAL ALGEBRA

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

Database Systems ( 資料庫系統 )

Key Points. COSC 122 Computer Fluency. Databases. What is a database? Databases in the Real-World DBMS. Database System Approach

Relational Design 1 / 34

FUNCTIONAL DEPENDENCIES CHAPTER , 15.5 (6/E) CHAPTER , 10.5 (5/E)

Logical Database Design Normalization

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

Data Modeling with the Entity Relationship Model. CS157A Chris Pollett Sept. 7, 2005.

An Introduction to Structured Query Language

High-Level Database Models (ii)

SQL Introduction. CS 377: Database Systems

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

ACS-2914 Normalization March 2009 NORMALIZATION 2. Ron McFadyen 1. Normalization 3. De-normalization 3

PHP Queries and HTML Forms Lecture 23

The Relational Model and Relational Algebra

More Relational Algebra

Chapter 9. MORE SQL: Assertions, Views, and Programming Techniques. Constraints as Assertions. Assertions: An Example

CS 2451 Database Systems: Database and Schema Design

The Relational Model

The Relational Model. Chapter 3. Comp 521 Files and Databases Fall

Transcription:

Name: W#: CS430 Final March 14, 2005 Write your answers in the space provided. Use the back of the page if you need more space. Values of questions are as indicated. 1. (4 points) What are the four ACID properties? Atomicity Consistency Isolation Durability 2. (4 points) Choose one of the acid properties and provide a definition of the property and explain why that property is important. (Hint: What can go wrong if that property doesn t hold.) Atomicity Without this, as result of a failure, partially completed transactions might be applied to the database. Consistency Without this, the database might be left in an inconsistent state. Or, an intermediate state, as perceived by another transaction might be inconsistent. Isolation Without this, transactions executing in parallel might interact in surprising and unfortunate ways. Durability Without this, completed transactions might be lost as a result of a failure, leaving the users not knowing what had and had not been done. 3. (8 points) In terms of the Relational Data Model explain the difference between a Superkey, a Candidate Key, and a Primary Key. Superkey a subset of the fields that uniquely determines the tuples in a relation. Candidate Key a minimal superkey in the sense that no field can be removed from the key and have it still remain a superkey. Primary Key a chosen, single, Candidate Key. 4. (4 Points) Provide an example of Impedance Mismatch between SQL and ordinary programming languages. There are a large number of possibilities here. Some examples: Database types (e.g. dates, numbers) don't exist in the host language or don't have the same ranges, for example, as the types in the host language. The host language uses objects, the database has tuples and rows but no objects. Page 1 of 7

Consider the following Entity Relationship diagram: Division 1 Part of FName LName Name Phone DeptName N Department 1 N Works For Person M Works On N Project Hourly Salary Proj Number Proj Name 5. (20 Points) Provide a relational schema (named relations and attributes for those relations) for this ER diagram. Make sure to show keys and foreign key relationships. Division Department DeptName Person FName LName DeptName Phone Phone Works On ProjNumber Hourly Salary Project ProjNumber ProjName Page 2 of 7

For questions 6 to 13, consider the following relational schema: Employee Name Sex DeptNum Department DeptNum DeptName Department_s DeptNum DeptLoc Project ProjName ProjNum ProjLoc DeptNum Works_On ProjNum Hours Write SQL for the following. (Hint: You may have to use EXISTS or NOT EXISTS.) 6. (3 points) Retrieve the names of all employees in Department 6. If there are multiple employees with the same name, the name should be repeated as many times as there are employees with that name. SELECT Name FROM Employee WHERE DeptNum = 6; 7. (3 points) Retrieve the names of all employees in Department 6. If there are multiple employees with the same name, the name should only appear once. SELECT DISTINCT Name FROM Employee WHERE DeptNum = 6; 8. (3 points) Retrieve the numbers and names of all departments with a location that begins with H. SELECT D.DeptName, D.DeptNum FROM Department D JOIN Department_s DL ON D.DeptNum = DL.DeptNum WHERE DL.DeptLoc LIKE 'H%'; Page 3 of 7

9. (4 points) Retrieve the names of all employees in Department 6 who do not work on Project XYZ. My choice (others accepted): SELECT Name FROM Employee WHERE DeptNum = 6 AND NOT EXISTS (SELECT * FROM Project P JOIN Works_On W ON P.ProjNum = W.ProjNum WHERE P.ProjName = 'XYZ' AND W. = Employee.); 10. (4 points) For each project list the project name and the total hours per week (by all employees) spent on the project. SELECT ProjName, SUM(Hours) FROM Project P JOIN Works_On W ON P.ProjNum = W.ProjNum GROUP BY ProjName; 11. (5 points) Retrieve the names of all employees who work on at least one project located in Houston but whose department has no location in Houston. My choice: SELECT Name FROM Employee E WHERE EXISTS ( SELECT * FROM Project P JOIN Works_On W ON P.ProjNum = W.ProjNum WHERE P.ProjLoc = 'Houston' AND W. = E.) AND NOT EXISTS ( SELECT * FROM Department D JOIN Department_s L ON D.DeptNum = L.DeptNum WHERE L.DeptLoc = 'Houston' AND D.DeptNum = E.DeptNum) Page 4 of 7

12. (3 points) Add an employee named John Doe with 123456789, Sex M, and Department Number 5 to the database. INSERT INTO Employee VALUES (123456789, 'John Doe', 'M', 5); or, for example, INSERT INTO Employee SET Name='John Doe', =123456789, Sex='M', DeptNum=5; 13. (3 points) Increase the number of hours for all employees working on Project Number 123 by 10%. UPDATE Works_On SET Hours = Hours * 1.1 WHERE ProjNum = 123; Page 5 of 7

Consider the following relation with the indicated Functional Dependencies: Projects Name DeptNo DName ProjN o PName PMgr Hours Budget {} Name, DeptNo, DName {DeptNo} DName {ProjNo} DeptNo, PName, Budget, PMgr {DeptNo, PName} ProjNo, Budget, PMgr {PMgr} DeptNo {, ProjNo} Hours For each of the tables shown below answer one of: N (No or None) if the table is not in Second Normal Form 2 (2NF or Second Normal Form) if the table is Second Normal Form but not Third Normal Form 3 (3NF or Third Normal Form) if the table is in Third Normal Form. 14. 3 (4 points) Name 15. 2 (4 points) Name DeptNo DName 16. N (4 points) Name ProjNo Hours Key is (, ProjNo) 17. 3 (4 points) ProjNo DeptNo PName Budget 18. 3 (4 points) ProjNo DeptNo PName PMgr Budget Note: #18 really is in third normal form. The fact that PMgr determines DeptNo does not invalidate this since (DeptNo, Pname) is an alternate key and that makes DeptNo a prime attribute. This is very similar to the example shown in Figure 10.12 in the book. This relation is third normal form but not Boyce-Codd normal form. Page 6 of 7

19. (12 Points) Provide an outline (show the major steps, not just a SELECT statement) for a host language program that runs a query with parameters (e.g. Dept Number is a user specified input) and outputs the results of the query. Example: An outline for reading a file and outputting it might look something like: 1. Get the file name from the user. 2. OPEN the file using the file name. 3. For each line in the file do steps 3.1 and 3.2: 3.1 READ the line 3.2 Output the line 4. CLOSE the file Something along the lines of: 1. Open a CONNECTION to the database. 2. Get the parameter from the user. 3. Create a CURSOR. 4. Execute the query using the cursor, attaching the parameter to the query. 5. Until there are no more rows to be fetched: 1. FETCH the next row from the CURSOR. 2. Output the row. 6. Close the CURSOR. 7. Close the CONNECTION. There were a lot of variations accepted for this one. Page 7 of 7