Database Management

Similar documents
Database Management

CSE 444 Midterm Test

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

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

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

Options. Real SQL Programming 1. Stored Procedures. Embedded SQL

Database Management Systems Paper Solution

BIRKBECK (University of London)

The Relational Data Model

A7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

Functional Dependencies CS 1270

Real SQL Programming Persistent Stored Modules (PSM)

Introduction to Database Systems. Announcements CSE 444. Review: Closure, Key, Superkey. Decomposition: Schema Design using FD

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

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

SOLUTIONS TO THE FINAL EXAMINATION Introduction to Database Design Spring 2011

CSCD43: Database Systems Technology. Lecture 4

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

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

The Relational Model

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

Fundamentals of Database Systems

Database Management Systems (Classroom Practice Booklet Solutions)

DATABASE MANAGEMENT SYSTEMS

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

The data structures of the relational model Attributes and domains Relation schemas and database schemas

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

Databases 1. SQL/PSM and Oracle PL/SQL

Northern India Engineering College, New Delhi Question Bank Database Management System. B. Tech. Mechanical & Automation Engineering V Semester

Chapter 8 INTEGRITY 1

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

Midterm Exam (Version B) CS 122A Spring 2017

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

Chapter 9: Object-Based Databases

A tuple is dangling if it doesn't join with any

SCHEMA REFINEMENT AND NORMAL FORMS

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

CMSC 461 Final Exam Study Guide

The Entity-Relationship Model

Database Management Systems. Chapter 3 Part 2

Solutions to Final Examination

Lecture 2: Introduction to SQL

CSE 562 Database Systems

T-SQL Training: T-SQL for SQL Server for Developers

High-Level Database Models (ii)

The Entity-Relationship Model. Overview of Database Design

Desired properties of decompositions

CS 317/387. A Relation is a Table. Schemas. Towards SQL - Relational Algebra. name manf Winterbrew Pete s Bud Lite Anheuser-Busch Beers

Part I: Structured Data

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

High Level Database Models

3 February 2011 CSE-3421M Test #1 p. 1 of 14. CSE-3421M Test #1. Design

Assign expressions to declared variables with :=. END IF; EXIT WHEN éconditioné END LOOP;

CSE 344 Final Examination

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


The Relational Model 2. Week 3

Sankalchand Patel College of Engineering, Visnagar B.E. Semester III (CE/IT) Database Management System Question Bank / Assignment

user specifies what is wanted, not how to find it

From E/R Diagrams to Relations

CSE 444 Midterm Exam

L Information Systems for Engineers. Final exam. ETH Zurich, Autumn Semester 2017 Friday

Chapter 9 SQL in a server environment

Running Example Tables name location

Typical relationship between entities is ((a,b),(c,d) ) is best represented by one table RS (a,b,c,d)

Final Review. Zaki Malik November 20, 2008

SQL Interview Questions

Chapter 1 SQL and Data

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

Midterm Exam #1 Version A CS 122A Winter 2017

Relational Model, Relational Algebra, and SQL

Midterm 2: CS186, Spring 2015

CS54100: Database Systems

2011 DATABASE MANAGEMENT SYSTEM

Introduction to Databases, Fall 2003 IT University of Copenhagen. Lecture 4: Normalization. September 16, Lecturer: Rasmus Pagh

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

Case Study: Lufthansa Cargo Database

Schedule. Feb. 12 (T) Advising Day. No class. Reminder: Midterm is Feb. 14 (TH) Today: Feb. 7 (TH) Feb. 21 (TH) Feb. 19 (T)

CSE 444, Fall 2010, Midterm Examination 10 November 2010

Entity-Relationship Model. Purpose of E/R Model

CS 461: Database Systems. Final Review. Julia Stoyanovich

Informatics 1: Data & Analysis

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

Essay Question: Explain 4 different means by which constrains are represented in the Conceptual Data Model (CDM).

Solutions. Updated of 7

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

QUIZ 1 REVIEW SESSION DATABASE MANAGEMENT SYSTEMS

UNIT 3 DATABASE DESIGN

Database Management Systems (Solutions for Vol 1_Classroom Practice Questions)

Database Design Principles

Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

CSIT5300: Advanced Database Systems

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Relational Model. Topics. Relational Model. Why Study the Relational Model? Linda Wu (CMPT )

The Relational Data Model. Functional Dependencies. Example. Functional Dependencies

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

Chapter 2: Intro to Relational Model

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

The Relational Model. Chapter 3

Data about data is database Select correct option: True False Partially True None of the Above

Transcription:

Database Management - 2013 Model Answers 1. a. A cyclic relationship type (also called recursive) is a relationship type between two occurrences of the same entity type. With each entity type in a cyclic relationship type we associate a role, represented by labels on lines in an ERD. Name Address NI# Person Phones husband wife Married Roles are specified by husband and wife labels. The attributes of the table for entity type E should be those of E with the same primary key. The attributes of the table for relationship type R should be the role names, along with any other attributes for the relationship type. The primary key should be the composite key comprising both role attributes. COIY028H6 Page 1 of 9 c Birkbeck College 2013

b. A relation r over R satisfies X Y if whenever two rows in r have the same X-value they also have the same Y -value. An FD X Y holds on relation schema R if every allowable (legal) relation r over R satisfies X Y. Two FDs which are satisfied in the example relation are from Title Year, Year Title, Genre Title, and Genre Year. Two FDs which are violated by the example relation are from Title Genre, Title StarName, StarName Title, StarName Genre, StarName Year, Year Genre, Year StarName, Genre StarName, StarName, Year Genre, Title, Year Genre, and Title, Year, Genre StarName. The only FD which might hold in the example relation schema is Title Year. However, this assumes that there are no remakes of films with the same title. COIY028H6 Page 2 of 9 c Birkbeck College 2013

c. In embedded SQL, a preprocessor turns SQL statements into procedure calls that fit with the surrounding host-language code. All embedded SQL statements begin with EXEC SQL, so the preprocessor can find them easily. To connect SQL and the host-language program, the two parts must share some variables. In SQL, the shared variables must be preceded by a colon. They may be used as constants provided by the host-language program. They may get values from SQL statements and pass those values to the host-language program. In the host language, shared variables behave like any other variable. Example: EXEC SQL BEGIN DECLARE SECTION; char thebar[21], thebeer[21]; float theprice; EXEC SQL END DECLARE SECTION; /* obtain values for thebar and thebeer */ EXEC SQL SELECT price INTO :theprice FROM Sells WHERE bar = :thebar AND beer = :thebeer; /* do something with theprice */ [Total 33 marks] COIY028H6 Page 3 of 9 c Birkbeck College 2013

2. a. In the foreign key definition, we can specify either ON DELETE CASCADE ON UPDATE CASCADE for actions on the referenced relation to cascade to the referencing relation, or ON DELETE SET NULL ON UPDATE SET NULL for the referencing relation s values to be set to null. Cascading deletes or updates is appropriate when changes to an entity need to be propagated throughout the database. Setting values to null is appropriate when we want the referencing entities to become independent after updates. b. (AB) + = ABCD (C) + = CD (BD) + = ABCD (E) + = CDE One BCNF decomposition would be as follows. Decompose ABCDE into CD and ABCE based on the FD C D since C is not a superkey. Then decompose ADCE into ABC and ABE based on AB C since AB is not a superkey. The final decomposition is thus CD, ABC and ABE. c. i. A domain dependency is a constraint on the allowed values for some attribute. For example, age might be restricted to being between 18 and 75. ii. An ISA relationship type in the ER model allows for modelling of generalisation or specialisation hierarchies. For example, one can state that student ISA person. Attributes are inherited down the hierarchy. iii. A natural join operation is a join over relations with common attribute names. The join condition is automatically taken to be checking for equality between pairs of attivute values with the same name. COIY028H6 Page 4 of 9 c Birkbeck College 2013

iv. Dependency preservation refers to whether or not a decomposition allows for all original functional dependencies to be checked by the database system by considering only each relation individually, i.e., no joins are needed to check whether or not dependencies are preserved when applying an update. v. Stored procedures correspond to code in a specialized language which is stored in the database itself (e.g., PSM, PL/SQL). PSM, or persistent stored modules, allows us to store procedures as database schema elements. PSM is a mixture of conventional statements (if, while, etc.) and SQL. Lets us do things we cannot do in SQL alone. We can CREATE PROCEDUREs, e.g., and then CALL them from within SQL queries. [Total 33 marks] COIY028H6 Page 5 of 9 c Birkbeck College 2013

3. a. The primary key for R1 would be A. The primary key for R2 would be AC. There would be a foreign key constraint on A in R2 referencing R1. The A value in relation R1 might be updated without the A value in R2 being similarly updated. A decomposition of R(A,B,C) into R1(A,B) and R3(B,C) would be lossy, i.e., the join of R1 and R3 might return tuples not in the original R from which R1 and R3 were decomposed. b. The inner join would produce person location name location Alice Cambridge St John s Chop House Cambridge Carol Cambridge St John s Chop House Cambridge Rows from person with value Cambridge for location join with rows from restaurant with value Cambridge for location. Rows with a null value for location do not join because null is not equal to null. In addition, location Hitchin does not appear in the person table, so does not join with any row. Left-outer join would include a row with person Bob and nulls for all other attributes. Right-outer join would include rows for MacDonald s and Pizza Express with nulls for person and (first) location. COIY028H6 Page 6 of 9 c Birkbeck College 2013

c. First normal form means that each attribute value in a relation should be atomic as far as the database system is concerned. Object-relational systems allow attributes to be defined using array types and multiset types. An example is given below, where the authors attribute can contain up to 10 strings, and keywords is a multiset of strings. CREATE TYPE Book AS ( title varchar(20), authors varchar(20) array [10], keywords varchar(20) multiset) NOT FINAL; [Total 33 marks] COIY028H6 Page 7 of 9 c Birkbeck College 2013

Page 8 of 5 4. a. i. A key is given by {Track, Artist, Role}. This functionally determines all attributes because Track TrackTitle, Track Album, and Album AlbumTitle. No subset of these attributes determines the full set. ii. The three FDs form a canonical cover. Each then forms a relation schema as follows: (Track, TrackTitle), (Album, AlbumTitle) and (Track, Album). Then we add another relation schema which forms a key, namely, (Track, Artist, Role). b. Transactions handle the problem that multiple programs accessing the database might try to modify the same data at the same time, leading to unpredictable results. Dirty data refers to data written by a transaction that has not yet committed. A dirty read operation is a read of dirty data written by another transaction. The risk is that the transaction that wrote the data may abort which would result in non-serializable behaviour. This may or may not be a problem for the reading transaction. If it performing some operation which not not require precise accuracy at that particular moment in time, it would not be a problem. c. Updating a database through a view can be problematic because such an update may be ambiguous, that is, it may not be obvious what updates to apply to the tables on which the view is defined. An SQL view is said to be updatable if the query defining the view satisfies the following: The FROM clause has only one database relation. The SELECT clause contains only attribute names of the relation (no expressions, aggregates, or DISTINCT). Any attribute not listed in the SELECT clause can be set to null. There is no GROUP BY clause. [Total 33 marks]

c Birkbeck College 2010 COIY028U END OF PAPER COIY028H6 Page 9 of 9 c Birkbeck College 2013