Answers to Midterm - Exam. Feb. 28, 2018

Slides:



Advertisements
Similar presentations
The Relational Calculus
Advertisements

TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
Defined by Edgar Codd in 1970 Defined by Edgar Codd in 1970 Considered ingenious but impractical Considered ingenious but impractical Conceptually simple.
Transactions (Chapter ). What is it? Transaction - a logical unit of database processing Motivation - want consistent change of state in data Transactions.
COMPANY schema EMPLOYEE
OUTLINE OF THE LECTURE PART I GOAL: Understand the Data Definition Statements in Fig 4.1 Step1: Columns of the Tables and Data types. Step2: Single column.
Exploring Microsoft Access 2003 Chapter 4 Proficiency: Relational Databases, External Data, Charts, Pivot, and the Switchboard.
Transaction Processing: September 27, Database Access For TP, represent database as a collection of named items. Read(X) - read database item X.
Concurrency control using transactions 1Transactions.
ICS (072)Transaction Processing Concepts and Theory 1 Introduction to Transaction Processing Concepts and Theory Chapter 17 Dr. Muhammad Shafique.
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
Analysis of Midterm-Examination Jan. 2010ACS-7102 Yangjun Chen1 1.(15) Draw an ER-diagram to describe the following real world problem. (a)A university.
Jan. 2014Dr. Yangjun Chen ACS Query Processing and Optimization Outline (Ch. 18, 3 rd – Ch. 15, 4 th ed. 5 th ed., Ch 19, 6 th ed.) Processing a.
1 Introduction to Transaction Processing (1)
1 BASIC TRANSACTION CONCEPTS A Transaction: logical unit of database processing that includes one or more access operations (read -retrieval, write – insert.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 21 Introduction to Transaction Processing Concepts and Theory.
Transaction Processing
관계 연산자 & SQL. Selection SELECT * FROM r WHERE A=B AND D>5.
Review: Application of Database Systems
Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter Introduction to Transaction.
Relational Algebra - Chapter (7th ed )
Query Processing and Optimization
Retrieve the names of all employees in department 5 who work more than 10 hours per week on the ‘ProductX’ project. p10ssn ← (Π essn (σ hours > 10 (works-on.
1 Chapter 4 Introduction to Transaction Processing Concepts and Theory Adapted from the slides of “Fundamentals of Database Systems” (Elmasri et al., 2003)
 Employee (fname, minit, lname, ssn, bdate, address, sex, salary, superssn, dno)  Department (dname, dnumber, mgrssn, mgrstartdate) 
Database Management Systems. NESTING OF QUERIES  Some queries require that existing values in the database be retrieved and then used in a comparison.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
CSCI Transaction Processing Concepts 1 TRANSACTION PROCESSING CONCEPTS Dr. Awad Khalil Computer Science Department AUC.
Transaction Processing The main reference of this presentation is the textbook and PPT from : Elmasri & Navathe, Fundamental of Database Systems, 4th edition,
Fan Qi Database Lab 1, com1 #01-08 CS3223 Tutorial 9.
NOEA/IT - FEN: Databases/Transactions1 Transactions ACID Concurrency Control.
1 Controlled concurrency Now we start looking at what kind of concurrency we should allow We first look at uncontrolled concurrency and see what happens.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 16 A First Course in Database Systems.
CSE314 Database Systems Introduction To Transaction Processing Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Lecture 5 Introduction to Transaction Processing Concepts and Theory.
Query Processing and Optimization
The SQL Database Grammar
CS580 Advanced Database Topics
Transaction processing concepts
6/22/2018.
Database Design The Relational Model Text Ch5
1 Introduction to Transaction Processing (1)
Chap 20 – Transaction Processing
Database System Implementation CSE 507
Mapping ER Diagrams to Tables
Joining Tables ضم الجداول وإستخراج مناظر views منها الهدف : 1- استخراج المعلومات من جدولين أو اكثر بالإستفادة من الرابط بينهما وبإستخدام SQL 2- شروط قواعد.
Transactions Properties.
Introduction to Transaction Processing Concepts and Theory
Company Requirements.
Heapsort.
12/4/2018.
Introduction to Transaction Processing Concepts and Theory
Query Processing and Optimization, Concurrency Control
1 Introduction to Transaction Processing (1)
(a) A university is organized into faculties.
CSCI 6315 Applied Database Systems – Exercise (6)
Design and Analysis of Algorithms
Structured Query Language (3)
2/23/2019.
Lec 9: Introduction to Transaction Processing Concepts and Theory
1. Explain the following concepts: (a) superkey (b) key
1.(5) Describe the working process with a database system.
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
(a) A university is organized into faculties.
1. Explain the following concepts of the ER data model:
C. Faloutsos Transactions
SQL Grouping, Ordering & Arithmetics Presented by: Dr. Samir Tartir
Outline Introduction Background Distributed DBMS Architecture
Answers to Midterm - Exam. Feb. 27, 2006
Presentation transcript:

Answers to Midterm - Exam. Feb. 28, 2018 1. (20) (i)What is the ACID principle? (10) (ii) By the heap-sorting, a sequence of integers is considered to be stored in a nearly complete binary tree, called a heap. Please give the algorithm for heap-sorting. (10) Answer: (i) Atomic – a transaction is done in its entirety, or not at all Consistent – a transaction leaves the database in a correct state. This is generally up to the programmer to guarantee. Isolation – a transaction is isolated from other transactions so that there is not adverse inter-transaction interference Durable – once completed (committed) the result of the transaction is not lost. 11/23/2019

2. for i  length[A] downto 2 3. do exchange A[1]  A[i] HeapSort(A) 1. BuildMaxHeap(A) 2. for i  length[A] downto 2 3. do exchange A[1]  A[i] 4. heap-size[A]  heap-size[A] – 1 5. MaxHeapify(A, 1) BuildMaxHeap(A) 1. heap-size[A]  length[A] 2. for i  length[A]/2 downto 1 (*A[length[A]/2 +1], 3. do MaxHeapify(A, i) A[length[A]/2 +2], … are leaf nodes.*) 11/23/2019

3. if l  heap-size[A] and A[l] > A[i] 4. then largest  l MaxHeapify(A, i) 1. l  left(i) 2. r  right(i) 3. if l  heap-size[A] and A[l] > A[i] 4. then largest  l 5. else largest  i 6. if r  heap-size[A] and A[r] > A[largest] 7. then largest  r 8. if largest i 9. then exchange A[i]  A[largest] 10. MaxHeapify(A, largest) 11/23/2019

2.(20) Given the following schedules, show which is recoverable, non-recoverable, cascadeless or strict. (a) R1(X), R3(X), W1(X), R1(Y), W2(Y), W2(X), W3(X), C1, C3, R2(X), C2. (6) (b) R1(X), R2(X), W1(X), R1(Y), R3(Y), W2(X), C2, W1(Y), C1, W3(Y), C3. (6) (c) R1(X), W1(X), R2(X), R1(Y), W2(X), C2, A1. (4) (d) R1(X), W1(X), R2(X), R1(Y), W2(X), W1(Y), A1, A2. (4) (a) cascadeless (b) cascadeless (c) non-recoverable (d) recoverable   11/23/2019

not yet committed. When the system crashes as shown in Fig. 1, how do 3.(20) (a) Tell the difference between commit points and checking points. (10) (b) Assume that at a checking point, all the changes made by transactions will be stored in the database, no matter whether they are committed or not yet committed. When the system crashes as shown in Fig. 1, how do we undo or redo the transactions? Here, we assume that all these transactions are not interferenced. (10) Time T1 T2 T3 T4 T5 Time of checkpoint failure Fig. 1 11/23/2019

The DBMS force-writes all changes/updates made by a 3. (a) A transaction has committed when it has finished all this work. At this point: The DBMS force-writes all changes/updates made by a transaction to the log. A commit record for the Transaction is also established in the log. A checkpoint occurs periodically. At this time point: The DBMS force-writes all the changes made by transactions into the database. In addition, a checkpoint record will be stored in the log. 3. (b) T1 – redone T2 – no redo, no undo T3 – no redo, no undo T4 – redone T5 – undone 11/23/2019

4.(20)Given the relation schemas shown below, generate an optimal query tree for the following query: SELECT fname, lname FROM EMPLOYEE, DEPARTMENT, PROJECT, WORKS_ON WHERE salary > 50000 and Pname = ‘Web Database’ and Pnumber = PNO and hours > 30 and dno = dnumber and Dname = ‘CS’ and ssn = ESSN 11/23/2019

Dname, dnumber, mgrssn, mgrstartdate DEPARTMENT Dname, dnumber, mgrssn, mgrstartdate EMPLOYEE fname, minit, lname, ssn, bdate, address, sex, salary, superssn, dno PROJECT Pname, Pnumber, Plocation, Dnum WORKS_ON ESSN, PNO, HOURS 11/23/2019

fname, lname((salary >50000(Employee) Dname=’CS’(Department) dno=Dnumber ((hours >30( Works_on) Pname=’web database’(Project)) ssn=ESSN PNO=Pnumber 11/23/2019

Question 4 fname, lname salary>50000 and Dname = ‘CS’and hours >30 and PNO=Pnumber and ESSN=SSN and Pname=‘web database’   Project  Works_on Dept. Employee 11/23/2019

Pname= ‘web database’ fname, lname  PNO=Pnumber   ssn=ESSN Pname= ‘web database’  Project  Dnumber=Dno  hours >30  Works_on  Dname = ‘CS’  salary>50000 Dept. Employee 11/23/2019

Pname= ‘web database’ fname, lname PNO=Pnumber ssn=ESSN Pname= ‘web database’ Project Dnumber=dno hours > 30 Dname=’CS’ salary > 50000 Dept. Employee Works_on 11/23/2019

Pname= ‘web database’ fname, lname, ssn ESSN, PNO Project PNO=Pnumber fname, lname, PNO Pnumber ssn=ESSN Pname= ‘web database’ fname, lname, ssn ESSN, PNO Project Dnumber=dno Dept. Dname=’CS’ dnumber fname, lname, ssn, dno hours > 30 salary > 50000 Employee Works_on 11/23/2019

5(i) Consider the following transactions T1 and T2, which execute concurrently. Is the result of this execution correct? Explain your answer and try this for X = 10, Y = 20, N = 5 and M = 8. (5) T1 Read(X) X := X - N Write(X) Read(Y) Y := Y + N Write(Y) Commit T2 Read(X) X := X + M Write(X) Commit 11/23/2019

5(ii) If the two transactions are executed interleavingly as follows and the initial values for X and Y are 20 and 30, respectively, what are the values of X and Y after the execution. Explain whether it is correct by using the concept of conflict equivalence. (5) T1 read_item(Y) read_item(X) X :=X+Y write_item(X) Commit T2 read_item(X) read_item(Y) Y:=X+Y write_item(Y) Commit 11/23/2019

It suffers the so-called lost-update problem. Answer: 5(i) The result produced by the interleaved transaction is not correct. It suffers the so-called lost-update problem. After this interleaved execution, X becomes 5 and Y becomes 25. The result of the serial execution is X = 13 and Y = 25. The corresponding schedule is not serializable due to the two conflict pairs: r1(x), w2(x); r2(x), w1(x). r1(x), r2(x), w1(x), r1(y), w2(x), w1(y) 11/23/2019

It suffers the so-called incorrect summary problem. Answer: 5(ii) The result produced by the interleaved transaction is not correct. It suffers the so-called incorrect summary problem. After this interleaved execution, both X and Y are equal to 50. The result of the serial execution is: if T1 is before T2, then X = 50 and Y = 80; if T2 is before T1, then X = 50 and Y = 70. The corresponding schedule is not serializable due to the two conflict pairs: r1(y), w2(y); r2(x), w1(x). r1(y), r2(x), r2(y), w2(y), r1(x), w1(x) 11/23/2019

6. (10) (i) Please explain whether the following identity holds. (5) L(R  S)  L(R)  L(S),   where R and S are two tables, and L is a list of attributes. (ii) Show the following identity always holds. (5) Not (c1 OR c2)  (Not c1) AND (Not c2), where c1 and c2 are two boolean variables. 11/23/2019

The identity does not hold. See the following counter-example: Answer: The identity does not hold. See the following counter-example: R = A B 2 3 1 S = A B 1 3 2 A 1 A 1 2 A(R  S) = A(R)  A(S) = They are not equal. 11/23/2019

The identity holds as shown below. Answer: The identity holds as shown below. c1 c2 Not (c1 OR c2) (Not c1) AND (Not c2) 1 11/23/2019