Similar documents

Database Management Systems Paper Solution

Graph-based protocols are an alternative to two-phase locking Impose a partial ordering on the set D = {d 1, d 2,..., d h } of all data items.

DATABASE MANAGEMENT SYSTEMS

Babu Banarasi Das National Institute of Technology and Management

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

SQL Interview Questions

CMSC 461 Final Exam Study Guide

Chapter 13 : Concurrency Control

Rajiv GandhiCollegeof Engineering& Technology, Kirumampakkam.Page 1 of 10

! A lock is a mechanism to control concurrent access to a data item! Data items can be locked in two modes :

Chapter 12 : Concurrency Control

Advanced Databases. Lecture 9- Concurrency Control (continued) Masood Niazi Torshiz Islamic Azad University- Mashhad Branch

AC61/AT61 DATABASE MANAGEMENT SYSTEMS JUNE 2013

ROEVER ENGINEERING COLLEGE

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

SYED AMMAL ENGINEERING COLLEGE

Chapter 15 : Concurrency Control

2 nd Semester 2009/2010

CHAPTER 3 RECOVERY & CONCURRENCY ADVANCED DATABASE SYSTEMS. Assist. Prof. Dr. Volkan TUNALI

DATABASE MANAGEMENT SYSTEM SHORT QUESTIONS. QUESTION 1: What is database?

transaction - (another def) - the execution of a program that accesses or changes the contents of the database

Foundation of Database Transaction Processing. Copyright 2012 Pearson Education, Inc.

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

Lecture 22 Concurrency Control Part 2

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

Administration Naive DBMS CMPT 454 Topics. John Edgar 2

In This Lecture. Exam revision. Main topics. Exam format. Particular topics. How to revise. Exam format Main topics How to revise

Transaction Management

Chapter 20 Introduction to Transaction Processing Concepts and Theory

Unit 2. Unit 3. Unit 4

A7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

References. Transaction Management. Database Administration and Tuning 2012/2013. Chpt 14 Silberchatz Chpt 16 Raghu

T ransaction Management 4/23/2018 1



Database Management System Prof. D. Janakiram Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

CS322: Database Systems Transactions

Final Review. May 9, 2017

Final Review. May 9, 2018 May 11, 2018

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

UNIT 4 TRANSACTIONS. Objective

Chapter 9: Transactions

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

Unit 10.5 Transaction Processing: Concurrency Zvi M. Kedem 1

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select,

DATABASE DESIGN I - 1DL300

Chapter 15: Transactions

CHAPTER: TRANSACTIONS

CS2255 DATABASE MANAGEMENT SYSTEMS QUESTION BANK UNIT I

Transaction Processing: Basics - Transactions

Q.1 Short Questions Marks 1. New fields can be added to the created table by using command. a) ALTER b) SELECT c) CREATE. D. UPDATE.

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

Transaction Management

Database Design Theory and Normalization. CS 377: Database Systems

Database Management System 15

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

Weak Levels of Consistency

mywbut.com Concurrency Control

Roadmap of This Lecture

Chapter 15: Transactions

CS/B.Tech/CSE/New/SEM-6/CS-601/2013 DATABASE MANAGEMENENT SYSTEM. Time Allotted : 3 Hours Full Marks : 70

Advances in Data Management Transaction Management A.Poulovassilis

Transactions and Concurrency Control. Dr. Philip Cannata

Chapter 13: Transactions

Functional Dependencies and Finding a Minimal Cover

TRANSACTION PROPERTIES

A lock is a mechanism to control concurrent access to a data item Data items can be locked in two modes:

D.K.M COLLEGE FOR WOMEN(AUTONOMOUS),VELLORE DATABASE MANAGEMENT SYSTEM QUESTION BANK

Chapter 5. Concurrency Control Techniques. Adapted from the slides of Fundamentals of Database Systems (Elmasri et al., 2006)

UNIT IV TRANSACTION MANAGEMENT

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

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

Overview of Transaction Management

The Relational Algebra

Transactions. Prepared By: Neeraj Mangla

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 17-1

Transactions. Silberschatz, Korth and Sudarshan

Chapter 14: Transactions

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

Advanced Databases (SE487) Prince Sultan University College of Computer and Information Sciences. Dr. Anis Koubaa. Spring 2014

Security Mechanisms I. Key Slide. Key Slide. Security Mechanisms III. Security Mechanisms II

Chapter 14: Transactions

ADVANCED DATABASES ; Spring 2015 Prof. Sang-goo Lee (11:00pm: Mon & Wed: Room ) Advanced DB Copyright by S.-g.

II B.Sc(IT) [ BATCH] IV SEMESTER CORE: RELATIONAL DATABASE MANAGEMENT SYSTEM - 412A Multiple Choice Questions.

BİL 354 Veritabanı Sistemleri. Transaction (Hareket)

Relational Design: Characteristics of Well-designed DB

Transaction Concept. Two main issues to deal with:

Introduction to Transaction Processing Concepts and Theory

CS Reading Packet: "Transaction management, part 2"

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 13 Managing Transactions and Concurrency

Lecture 20 Transactions

Transactions These slides are a modified version of the slides of the book Database System Concepts (Chapter 15), 5th Ed

Chapter 7 (Cont.) Transaction Management and Concurrency Control

Database Systems. Basics of the Relational Data Model

Advanced Databases. Transactions. Nikolaus Augsten. FB Computerwissenschaften Universität Salzburg

Database Management Systems

Sample Exam for CSE 480 (2017) KEY

ICOM 5016 Database Systems. Chapter 15: Transactions. Transaction Concept. Chapter 15: Transactions. Transactions

Transcription:

Q.2 e) Time stamping protocol for concurrrency control Time stamping ids a concurrency protocol in which the fundamental goal is to order transactions globally in such a way that older transactions get priority in the event of a conflict.

In this method, if a transaction attempts to read or write a data item, then a read or write operation is allowed only if the last updated on that data item was carried out by an older transaction. Otherwise the transaction, requesting the read or write is restarted and given a new timestamp. The restarted transaction is assigned a new timestamp to prevent it from continuously aborting and restarting. In this method, sequence of transaction is selected in advance by using time stamping concept. We associate a unique, fixed non-decreasing numbers called the timestamp to each transaction in the system. This number can be the system clock value, i.e. when the transaction enters the system the current value of the clock is assigned to that transaction as the timestamp value. We can also use a logical number that is incremented after a new transaction enters the system. A transaction with a smaller timestamp value is considered to be an adder transaction than another transaction with a larger time stamp value. In other words, if a transaction T1 has been assigned a timestamp S1 and a new transaction T2 enters the system with a time stamp value S2 then S1<S2 and system will allow the transaction T1 to run first followed by the transaction T2. If any conflict is found between transaction using timestamp based system, one of the conflicting transaction is rolled back. There are two types of timestamps: W-time stamp (Q): Denotes the largest time stamp of any transaction that executed write(q) successfully. R-Time stamp (Q): Denotes the largest time stamp of any transaction that executed read(q) successfully. Concurrency Control: Multi version Scheme Multiversion schemes keep old versions of data item to increase concurrency. Multiversion Timestamp Ordering Multiversion Two-Phase Locking Each successful write results in the creation of a new version of the data item written. Use timestamps to label versions. When a read(x) operation is issued, select an appropriate version of X based on the timestamp of the transaction, and return the value of the selected version. reads never have to wait as an appropriate version is returned immediately. Section C Answer. 3 a) Redundancy - Repetitive storage of data leading to possible multiple versions and/or ill utilisation of data storage capacity. Inconsistency - Failure to adhere to standardized storage of data; usage of varying formats, non-confirmation to standardized/defined methods to store similar/related data. File Systems Applications are developed on the fly Redundant information Inconsistency:

Answer 3 b) File Systems Data representation Each file has its own logical format File organisation varies with applications Programs access files in accordance with their access methods and logical format new format implies creating new file & accessing existing ones

Data Bases Remove redundancy: centralize all data, represent in exactly one place Provide global logical view Separate logical view from physical to allow customized logical views Enable sharing: all applications may run concurrently A data base is a central pool of data sharable among its many users loss of individual control of data response times in accordance with organisation needs Some main differences between a database management system and a file-processing system are: Both systems contain a collection of data and a set of programs which access that data. A database management system coordinates both the physical and the logical access to the data, whereas a file-processing system coordinates only the physical access. A databasemanagement system reduces the amount of data duplication by ensuring that a physical piece of data is available to all programs authorized to have access to it,whereas data written by one programin a file-processing system may not be readable by another program. A database management system is designed to allow flexible access to data (i.e., queries), whereas a file-processing system is designed to allow predetermined access to data (i.e., compiled programs). A database management system is designed to coordinate multiple users accessing the same data at the same time. A file-processing systemis usually designed to allow one or more programs to access different data files at the same time. In a fileprocessing system, a file can be accessed by two programs concurrently only if both programs have read-only access to the file. Answer 3 C)

Three level Architecture (ANSI/SPARC) File System is very low level record but no logical relationship, only physical position Operation in physical terms, not logical Define a logical level for a logical model A model is a set of concepts, relationships between these, and constraints DBA External layer Logical layer Internal/physical layer Define a user view of the model Data Base Views The Enterprise View The User s The User s The Logical Database The Physical Database

Database Roles Enterprise Manager:Ensures organisation mirroring DB A External layer Logical layer Applications Manager: For specific logical views Physical layer Answer 4 a) The relational algebra is a procedural query language. It consists of a set of operations that take one or two relation as input and produce a new relation as output. Relational algebra is the basic set of operations for the relational model These operations enable a user to specify basic retrieval requests (or queries) The result of an operation is a new relation, which may have been formed from one or more input relations Relational Algebra consists of several groups of operations Unary Relational Operations SELECT (symbol: (sigma)) PROJECT (symbol: (pi)) RENAME (symbol: (rho)) Relational Algebra Operations From Set Theory UNION ( ), INTERSECTION ( ), DIFFERENCE (or MINUS, ) CARTESIAN PRODUCT ( x ) Binary Relational Operations JOIN (several variations of JOIN exist) DIVISION Additional Relational Operations OUTER JOINS, OUTER UNION AGGREGATE FUNCTIONS (These compute summary of information: for example, SUM, COUNT, AVG, MIN, MAX) The Relational Calculus A relational calculus expression creates a new relation, which is specified in terms of variables that range over rows of the stored database relations (in tuple calculus) or over columns of the stored relations (in domain calculus).

In a calculus expression, there is no order of operations to specify how to retrieve the query result a calculus expression specifies only what information the result should contain. This is the main distinguishing feature between relational algebra and relational calculus. Relational calculus is considered to be a nonprocedural language. This differs from relational algebra, where we must write a sequence of operations to specify a retrieval request; hence relational algebra can be considered as a procedural way of stating a query. Answer. 4 b) Trigger : A series of PL/SQL statements attached to a database table that execute whenever a triggering event (select, update, insert, delete) occurs. Application/Database Triggers : PL/SQL block that is associated with an application even event/database table and is fired automatically A trigger is a PL/SQL code block attached to a database table. It is executed by an event (INSERT, UPDATE, DELETE) associated with that table. Triggers are thus implicitly invoked by DML commands. Triggers are stored as text and compiled at execution time, because of this it is wise not to include much code in them but to call out to previously stored procedures or packages as this will greatly improve performance. Remember that triggers may be executed thousands of times for a large update - they can seriously affect SQL execution performance. Answer 4 c) Example of Trigger

Example of Different Joins (Cross, Natural, Inner, Outer) Assume 2 tables A and B has values with the 1 st column of each table as the common column, in the following: Table A: 2 3 Table B: 1 A I 2 B II 4 D IV 1. Cross Join: append at the end of every row of Table A by every row of Table B. SQL command: select * from A cross join B; Result: 2 1 A I 2 2 B II 2 4 D IV 3 1 A I 3 2 B II 3 4 D IV 2. Natural Join: after Cross Join, pick up only rows with the same (or matching) common column values. Show the common column value only once SQL command: select * from A natural join B; Result: 2 B II 3. Inner Join: after Cross Join, pick up only rows with the same (or matching) common column values. However, show the common column values for both tables. You must specify the common column(s). SQL command: select * from A inner join B On A.commoncolumn=B.commoncolumn; Result: 2 2 B II Comparison of external join and Natural Join: Natural Join is special kind of syntax. Unlike explicit inner and outer join syntax. Natural join syntax has implicit join condition. It is both its strength and weaknessstrength because one can write a bit less words, weakness because it is quite dangerous and unprotected to structure changes of tables.

Assume 2 tables A and B has values with the 1 st column of each table as the common column, in the following: Table A: 2 3 Table B: 1 A I 2 B II 4 D IV Concrete Example: Table Course: NAME COURSE NUMBER John ITEC 122 Cindy ITEC 120 Table Student: NAME PHONE GPA NUMBER John 6391111 2.0 David 8311111 3.0 Cindy 7311111 4.0 1. Cross Join: append at the end of every row of Table A by every row of Table B. SQL command: select * from A cross join B; Result: 2 1 A I 2 2 B II 2 4 D IV 3 1 A I 3 2 B II 3 4 D IV 2. Natural Join: after Cross Join, pick up only rows with the same (or matching) common column values. Show the common column value only once. Must have common names between 2 tables. SQL command: select * from A natural join B; Result: 2 B II

Concrete Example: SQL: select * from Course natural join Student; Result: NAME COURSE NUMBER PHONE NUMBER GPA John ITEC 122 6391111 2.0 Cindy ITEC 120 7311111 4.0 3. Inner Join: after Cross Join, pick up only rows with the same (or matching) common column values. However, show the common matched column values for both tables. You must specify the common column(s). SQL command: select * from A inner join B On A.commoncolumn=B.commoncolumn; Result: 2 2 B II Concrete Example: SQL: select * from Course inner join Student On Course.Name= Student. Name; Result: NAME COURSE NUMBER NAME PHONE NUMBER GPA John ITEC 122 John 6391111 2.0 Cindy ITEC 120 Cindy 7311111 4.0 4. Outer Join: (1) Left Outer Join: after Inner Join, add rows of the left Table (A) which is non-matching common column values from row of Cross Join with all fields of Table B blanked. You must specify the common column(s). SQL command: select * from A left outer join B On A.commoncolumn=B.commoncolumn; Result: 2 2 B II 3 Concrete Example: If you want to find out who are new in the school (who don t have any GPA yet) SQL: select * from Course left outer join Student On Course.Name= Student. Name; Result: NAME COURSE NUMBER PHONE NUMBER GPA John ITEC 122 6391111 2.0

Cindy ITEC 120 7311111 4.0 (2) Right Outer Join: after Inner Join, add rows of the right Table (B) which is non-matching common column values from row of Cross Join with all fields of Table A blanked. You must specify the common column(s). SQL command: select * from A right outer join B On A.commoncolumn=B.commoncolumn; Result: 2 2 B II 1 A I 4 D IV Concrete Example: If you want to find out students who are not taking any class SQL: select * from Course right outer join Student On Course.Name= Student. Name; Result: NAME COURSE NUMBER PHONE NUMBER GPA John ITEC 122 6391111 2.0 David 8311111 3.0 Cindy ITEC 120 7311111 4.0 (3) Full Outer Join: after Inner Join, add rows of the left Table (A) and the right Table (B) which are non-matching common column values from row of Cross Join with all fields of the other Table blanked. You must specify the common column(s). SQL command: select * from A full join B On A.commoncolumn=B.commoncolumn; Result: 2 2 B II 3 1 A I 4 D IV Answer 5 a) Armstrong s axioms Reflexivity rule If A is a set of attributes and B A A B Augmentation rule If A B holds and C is a set of attributes CA CB

Transitivity rule If A B holds and B C holds A C These axioms are sound and complete they generate all other functional dependencies for a given set F of functional dependencies. Answer.5 b) Need of Normalization Result of E-R analysis need further refinement Appropriate decomposition can solve problems The underlying theory is referred to as normalization theory and is based on functional dependencies (and other kinds, like multi-valued dependencies) Normalization is a design technique that is widely used as a guide in designing relational databases. Normalization is essentially a two step process 1) that puts data into tabular form by removing repeating groups and 2) then removes duplicated data from the relational tables. Normalization theory is based on the concepts of normal forms. A relational table is said to be a particular normal form if it satisfied a certain set of constraints. Normalization is a process for assigning attributes to entities. It reduces data redundancies and helps eliminate the data anomalies. Normalization is a process of refining table structures into a proper state so that they can store data as efficiently as possible. Normalization works through a series of stages called normal forms: o First normal form (1NF) o Second normal form (2NF) o Third normal form (3NF) o Fourth normal form (4NF) The highest level of normalization is not always desirable. Answer.5 c)

Third Normal Form(3NF) Codd s Definition A relation is in 3NF if it satisfies 2NF and no nonprime attribute of R is transitively dependent on the primary key 3NF Decomposition Algorithm If A B and B C in R then create R1(A,B), R2 (B,C) Equivalently, A relation is in 3 NF if for every functional dependency X A, one of the following statements is true: i) it is a trivial FD X is a superkey A is a prime attribute Consider a relation Stdinf (Name, Phoneno, Course, Major, Prof., Grade, Major-Elective) with following FD s Name Course Phoneno Major Prof.. Grade Major-Elective The key of the relation is {Name Course} The partial dependencies are caused by Name Phoneno Name Major and Course Prof. The only transitive dependency is Name Major, Major Major-Elective.

Consider a relation Stdinf (Name, Phoneno, Course, Major, Prof., Grade, Major-Elective) with following FD s Name Course Phoneno Major Prof.. Grade Major-Elective The key of the relation is {Name Course} The partial dependencies are caused by Name Phoneno Name Major and Course Prof. The only transitive dependency is Name Major, Major Major-Elective. 3NF Decomposition: R1-1(Name,Phoneno,Major) R1-2(Major, Major-Elective) R2(Course, Prof.) R3(Name,Course,Grade) BCNF Need For BCNF arises when X A and A B where B is a subset of X Student (Name, Course, Teacher) and Name Course Teacher Note: Name, Course is the primary key of Student Name Course Teacher A C1 T1 B C1 T1 C C2 T2

A relation R is in BCNF if it is in 1NF and for every collection C of fields, if any field not in C is functionally dependent on C, then C R A relation is in BCNF if whenever a functional dependency X A holds then, either i) X is a super key of R, or ii) X A is trivial (A is subset of X) Difference with 3NF: A cannot be a prime attribute Lossless BCNF Decomposition For R(A,B,C) if A,B C and C B, decompose R into R1(C,B) and R2 (R - B) Note: Dependency Non-preserving Comparison of BCNF and 3NF Every BCNF relation is in 3 NF, but not vice versa. 3NF is Lossy and Dependency preserving. BCNF is Lossless and is not necessarily Dependency preserving Answer 6 a) Deadlock: when each of two transactions is waiting for the other to release an item. Approaches for solution: o deadlock prevention protocol: every transaction must lock all items it needs in advance o deadlock detection (if the transaction load is light or transactions are short and lock only a few items):

Livelock: a transaction cannot proceed for an indefinite period of time while other transactions in the system continue normally. o Solution: fair waiting schemes (i.e. first-come-first-served) The deadlock is different from starvation. Starvation is the problem that occurs when a process is waiting for a resource that is allocated to other processes, released, and then allocated again to some process other than the one that is starving. Answer 6 b) Purpose of Database Recovery To bring the database into the last consistent state, which existed prior to the failure. To preserve transaction properties (Atomicity, Consistency, Isolation and Durability). Example: If the system crashes before a fund transfer transaction completes its execution, then either one or both accounts may have incorrect value. Thus, the database must be restored to the state before the transaction modified any of the accounts. Transaction Roll-back (Undo) and Roll-Forward (Redo) To maintain atomicity, a transaction s operations are redone or undone. Undo: Restore all BFIMs on to disk (Remove all AFIMs). Redo: Restore all AFIMs on to disk. Database recovery is achieved either by performing only Undos or only Redos or by a combination of the two. These operations are recorded in the log as they happen. Answer 7a) ACID Properties To preserve integrity of data, the database system must ensure: 1. Atomicity. Either all operations of the transaction are properly reflected in the database or none are. 2. Consistency. Execution of a transaction in isolation preserves the consistency of the database. 3. Isolation. Although multiple transactions may execute concurrently, each transaction must be unaware of other concurrently executing transactions. Intermediate transaction results must be hidden from other concurrently executed transactions. a. That is, for every pair of transactions Ti and Tj, it appears to Ti that either Tj, finished execution before Ti started, or Tj started execution after Ti finished. 4. Durability. After a transaction completes successfully, the changes it has made to the database persist, even if there are system failures. Answer 7 b) Validation-Based Protocol

Execution of transaction Ti is done in three phases. 1. Read and execution phase: Transaction Ti writes only to temporary local variables 2. Validation phase: Transaction Ti performs a ``validation test'' to determine if local variables can be written without violating serializability. 3. Write phase: If Ti is validated, the updates are applied to the database; otherwise, Ti is rolled back. The three phases of concurrently executing transactions can be interleaved, but each transaction must go through the three phases in that order. Assume for simplicity that the validation and write phase occur together, atomically and serially I.e., only one transaction executes validation/write at a time. Also called as optimistic concurrency control since transaction executes fully in the hope that all will go well during validation Answer 7 c) Multiple Granularity Locking Scheme Transaction Ti can lock a node Q, using the following rules: 1. The lock compatibility matrix must be observed. 2. The root of the tree must be locked first, and may be locked in any mode. 3. A node Q can be locked by Ti in S or IS mode only if the parent of Q is currently locked by Ti in either IX or IS mode. 4. A node Q can be locked by Ti in X, SIX, or IX mode only if the parent of Q is currently locked by Ti in either IX or SIX mode. 5. Ti can lock a node only if it has not previously unlocked any node (that is, Ti is two-phase). 6. Ti can unlock a node Q only if none of the children of Q are currently locked by Ti. Observe that locks are acquired in root-to-leaf order, whereas they are released in leaf-to-root order.