Introduction to Databases



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

Exercise 1: Relational Model

IT2305 Database Systems I (Compulsory)

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

Scheme G. Sample Test Paper-I

DATABASE MANAGEMENT SYSTEMS. Question Bank:

Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks]

IT2304: Database Systems 1 (DBS 1)

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

CHAPTER 6 DATABASE MANAGEMENT SYSTEMS. Learning Objectives

Introduction to Database Systems. Normalization

Database Design and Normalization

Demystified CONTENTS Acknowledgments xvii Introduction xix CHAPTER 1 Database Fundamentals CHAPTER 2 Exploring Relational Database Components

CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina

Introduction to Databases

There are five fields or columns, with names and types as shown above.

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

Database Management. Technology Briefing. Modern organizations are said to be drowning in data but starving for information p.

Lecture 6. SQL, Logical DB Design

BCA. Database Management System

In This Lecture. Security and Integrity. Database Security. DBMS Security Support. Privileges in SQL. Permissions and Privilege.

Database Systems Introduction Dr P Sreenivasa Kumar

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

Entity/Relationship Modelling. Database Systems Lecture 4 Natasha Alechina

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

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. Introduction to Databases. Why databases? Why not use XML?

DESIGN DOCUMENT: BOOKS DATABASE

14 Databases. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

Lecture Notes on Database Normalization

Conceptual Design Using the Entity-Relationship (ER) Model

THE OPEN UNIVERSITY OF TANZANIA FACULTY OF SCIENCE TECHNOLOGY AND ENVIRONMENTAL STUDIES BACHELOR OF SIENCE IN INFORMATION AND COMMUNICATION TECHNOLOGY

Relational Database Design: FD s & BCNF

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

The process of database development. Logical model: relational DBMS. Relation

CS143 Notes: Normalization Theory

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

Database 2 Lecture I. Alessandro Artale

Foundations of Information Management

A Technique for Teaching Difficult Concepts in an Undergraduate Business Database Management Systems Course



DATABASE DESIGN. - Developing database and information systems is performed using a development lifecycle, which consists of a series of steps.

EECS 647: Introduction to Database Systems

Principles of Database Management Systems. Overview. Principles of Data Layout. Topic for today. "Executive Summary": here.

City University of Hong Kong. Information on a Course offered by Department of Computer Science with effect from Semester A in 2014 / 2015

Design of Relational Database Schemas

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

THE OPEN UNIVERSITY OF TANZANIA FACULTY OF SCIENCE TECHNOLOGY AND ENVIRONMENTAL STUDIES BACHELOR OF SIENCE IN DATA MANAGEMENT

Boyce-Codd Normal Form

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

Course: CSC 222 Database Design and Management I (3 credits Compulsory)

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. COURSE CURRICULUM COURSE TITLE: DATABASE MANAGEMENT (Code: ) Information Technology

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

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

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

SAMPLE FINAL EXAMINATION SPRING SESSION 2015

Databases Model the Real World. The Entity- Relationship Model. Conceptual Design. Steps in Database Design. ER Model Basics. ER Model Basics (Contd.

The Relational Model. Why Study the Relational Model?

Chapter 8. Database Design II: Relational Normalization Theory

Chapter 7: Relational Database Design

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Database Systems Concepts, Languages and Architectures

Databasesystemer, forår 2005 IT Universitetet i København. Forelæsning 3: Business rules, constraints & triggers. 3. marts 2005

Introduction to Access97 (2): Relationships. by Robin Beaumont. Contents 2. LEARNING OUTCOMES CHECK LIST FOR THE SESSION INTRODUCTION...

DBMS / Business Intelligence, SQL Server

Databases What the Specification Says

Database Security. Sarajane Marques Peres, Ph.D. University of São Paulo

SQL, PL/SQL FALL Semester 2013

THE BCS PROFESSIONAL EXAMINATION Diploma. October 2004 EXAMINERS REPORT. Database Systems

SQL Server. 1. What is RDBMS?

CPS352 Database Systems: Design Project

Alexander Nikov. 5. Database Systems and Managing Data Resources. Learning Objectives. RR Donnelley Tries to Master Its Data

B.Sc (Computer Science) Database Management Systems UNIT-V

Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES

Schema Refinement, Functional Dependencies, Normalization

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

Cognos 8 Best Practices

A Critical Review of Data Warehouse

Intro to Databases. ACM Webmonkeys 2011

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

Normalization in Database Design

The Structured Query Language. De facto standard used to interact with relational DB management systems Two major branches

Relational Database Design Theory

Chapter 23. Database Security. Security Issues. Database Security

Database Security. Chapter 21

A Brief Introduction to MySQL

CSE 562 Database Systems

A Multidimensional Design for the Genesis Data Set

CS 525 Advanced Database Organization - Spring 2013 Mon + Wed 3:15-4:30 PM, Room: Wishnick Hall 113

INFO/CS 330: Applied Database Systems

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur

The University of British Columbia

B2.2-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

DATABASE NORMALIZATION

Instructor: Michael J. May Semester 1 of The course meets 9:00am 11:00am on Sundays. The Targil for the course is 12:00pm 2:00pm on Sundays.

Topics. Database Essential Concepts. What s s a Good Database System? Using Database Software. Using Database Software. Types of Database Programs

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

Transcription:

Introduction to Databases IT University of Copenhagen January 7, 2005 This exam consists of 6 problems with a total of 16 questions. The weight of each problem is stated. You have 4 hours to answer all 16 questions. If you cannot give a complete answer to a question, try to give a partial answer. You may choose to write your answer in Danish or English. Your answers should appear in the same order as the corresponding questions. Remember to write the page number and your CPR-number on each page of your written answer. The complete assignment consists of 5 numbered pages (including this page). GUW refers to Database Systems The Complete Book by Hector Garcia-Molina, Jeff Ullman, and Jennifer Widom, 2002. All written aids are allowed / Alle skriftlige hjælpemidler er tilladt. 1

1 Database design (20%) Consider the following E/R diagram, modeling data about patients in a hospital: cpr Patients treats Doctors cpr name name occup has speciality since room family number Beds type Illnesses type a) Perform a conversion of the E/R diagram into relation schemas, using the method described in GUW. You should eliminate relations that are not necessary (e.g., by combining relations). Imagine you are given the task of integrating the database for the data of the E/R diagram with a database used for managing beds. It has the following relational database schema: Beds(room_id,bed_number,type,buy_date) Rooms(room_id,type,capacity) BedBookings(room_id,bed_number,from_date,to_date,patient_cpr) The Beds relation contains information on all beds in the hospital, including which room they are in. It corresponds to the Beds entity set, plus one additional attribute. The Rooms relation contains information about each room. Finally, the BedBookings relation contains information about what beds will be used in future, planned hospitalizations. It contains information on at most one hospitalization for each patient. b) Integrate the relational database schema in the E/R diagram above, and draw the complete E/R diagram. The resulting E/R diagram should have the property that it can be converted into relations using the method described in GUW, so that the relations Beds, Rooms, and BedBookings have exactly the above schemas. 2

2 Normalization (15%) Consider the relations Beds, Rooms, and BedBookings from Problem 1. After questioning the facilities management of the hospital, you have the following information about what kind of data can occur in these relations: The only key of Beds is (room id,bed number). All beds bought on the same date are of the same type. All beds in the same room were bought on the same date. The only key of Rooms is (room id). Rooms of the same type can have different capacities. There can be rooms of different types with the same capacity. The only key of BedBookings is (room id,bed number,patient cpr). The attribute to date is either NULL or larger than from date. a) Based on the above information, give an example of redundancy and an example of an update anomaly in the relations. b) Identify all avoidable functional dependencies in the three relation schemas (i.e., nontrivial functional dependencies that do not have a superkey on the left hand side). c) Based on the functional dependencies from b), perform a decomposition of the relations into BCNF. 3 Transactions (10%) Relation BedBookings from Problem 1 has three types of transactions performed on it: 1. Booking a bed. This involves finding a bed in Beds that only occurs in BedBookings with to date before a certain date, and using it for a new tuple in BedBookings. 2. Signing out a patient, i.e., setting the to date attribute to a certain date. 3. Gathering statistics, i.e., computing an aggregate on the relation. a) Suggest an appropriate SQL isolation level for each type of transaction. Argue in favour of your choices. 3

4 SQL and relational algebra (30%) Consider the relations Beds, Rooms, and BedBookings from Problem 1. a) Write an SQL query that computes the total capacity of all rooms where type is T. b) Write a query in SQL that computes the room ids and types of rooms with at least one bed having buy date < 1990. (If desired, you may use the fact from Problem 2 that all beds in the same room were bought on the same date.) Consider the following SQL expression: UPDATE BedBookings SET room_id=null, bed_number=null WHERE (room_id,bed_number) IN (SELECT room_id,bed_number FROM Beds WHERE type= OLD ); c) Give a short and precise explanation of what changes are performed on the data when the above expression is run. d) Write an SQL statement that sets the capacity of every room in Rooms to the number of beds that are currently in the room (as registered in the Beds relation). e) Write relational algebra expressions corresponding to the SQL of questions a) and b). 5 OLAP (10%) This problem concerns the construction of a relational OLAP system for data about traffic. Data for the system comes from a sensor that registers passing vehicles, and measures their speed and their type ( bike, car, van, or truck ). The sensor data is combined with information about the time and day of week, and the weather ( snowy, rainy, or dry ). a) Identify the facts, measures and dimensions to be used in an OLAP system for the traffic data. b) Give a star schema for the data. 4

6 SQL privileges (15%) Consider the relation BedBookings from Problem 1. Suppose that it is created by the user dba, who executes the following statements: GRANT SELECT ON BedBookings TO adm WITH GRANT OPTION; GRANT UPDATE ON BedBookings TO adm WITH GRANT OPTION; GRANT DELETE ON BedBookings TO adm; Subsequently, the user adm executes these statements (some of which may result in error messages from the DBMS): GRANT SELECT ON BedBookings TO doc; GRANT UPDATE(from_date,to_date) ON BedBookings TO doc WITH GRANT OPTION; GRANT DELETE ON BedBookings TO doc; a) State what kinds of rights (SELECT, UPDATE, DELETE) the user doc has on the relation BedBookings. Now assume that the user dba executes the following statements (some of which may result in error messages from the DBMS): REVOKE SELECT ON BedBookings FROM adm CASCADE; REVOKE UPDATE(from_date) ON BedBookings FROM adm CASCADE; b) State the rights of the user doc after the above REVOKE statements. The following SQL query returns all tuples in BedBookings concerning female patients, omitting the patient cpr attribute. (It uses the fact that females have even CPR numbers.) SELECT room_id,bed_number,from_date,to_date FROM BedBookings WHERE (patient_cpr%2=0); c) Write SQL statements that, if executed by the user dba, allows the user public to retrieve the information produced by the above query, but does not allow public to access any CPR numbers, or any tuples concerning males. Hint: First define a view. 5