Database Administration Part 1 Chapter Six CSCI260 Database Applications.

Slides:



Advertisements
Similar presentations
Database Administration Chapter Six DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
Advertisements

Module 15: Managing Transactions and Locks. Overview Introduction to Transactions and Locks Managing Transactions SQL Server Locking Managing Locks.
Database Administration Chapter Six DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Transaction Management and Concurrency Control
10 1 Chapter 10 Transaction Management and Concurrency Control Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 9 Managing Multi- User.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
© 2002 by Prentice Hall 1 SI 654 Database Application Design Winter 2003 Dragomir R. Radev.
What is a Transaction? Logical unit of work
© 2002 by Prentice Hall 1 SI 654 Database Application Design Winter 2004 Dragomir R. Radev.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 11 Managing Multi-User Databases.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 8-1 COS 346 Day 18.
Security and Transaction Management Pertemuan 8 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
Chapter 9 Transaction Management and Concurrency Control
Database Administration Part 2 Chapter Six CSCI260 Database Applications.
Database Administration
Database Administration Chapter Six DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
9 Chapter 9 Transaction Management and Concurrency Control Hachim Haddouti.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Management and Concurrency Control
Transactions and Locks Lesson 22. Skills Matrix Transaction A transaction is a series of steps that perform a logical unit of work. Transactions must.
Managing Transaction and Lock Vu Tuyet Trinh Hanoi University of Technology 1.
1 IT420: Database Management and Organization Transactions 31 March 2006 Adina Crăiniceanu
Database Administration
Multi-user Database Processing Architectures Architectures Transactions Transactions Security Security Administration Administration.
1 Transactions BUAD/American University Transactions.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
Chapterb19 Transaction Management Transaction: An action, or series of actions, carried out by a single user or application program, which reads or updates.
1cs Intersection of Concurrent Accesses A fundamental property of Web sites: Concurrent accesses by multiple users Concurrent accesses intersect.
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220m.htm
Unit 9 Transaction Processing. Key Concepts Distributed databases and DDBMS Distributed database advantages. Distributed database disadvantages Using.
Chapter 15 Recovery. Topics in this Chapter Transactions Transaction Recovery System Recovery Media Recovery Two-Phase Commit SQL Facilities.
Ch 10: Transaction Management and Concurrent Control.
1 IT420: Database Management and Organization Session Control Managing Multi-user Databases 24 March 2006 Adina Crăiniceanu
11/7/2012ISC329 Isabelle Bichindaritz1 Transaction Management & Concurrency Control.
Transactions and Locks A Quick Reference and Summary BIT 275.
© 2002 by Prentice Hall 1 Database Administration David M. Kroenke Database Concepts 1e Chapter 6 6.
Fundamentals, Design, and Implementation, 9/e Chapter 9 Managing Multi-User Databases.
1 IT420: Database Management and Organization Managing Multi-user Databases 29 March 2006 Adina Crăiniceanu
© 2006 ITT Educational Services Inc. Course Name: IT390 Business Database Administration Unit 8 Slide 1 IT 390 Business Database Administration Unit 8:
KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall 6-1 Chapter Objectives Understand the need for and importance of database.
David M. Kroenke and David J. Auer Database Processing: F undamentals, Design, and Implementation Chapter Nine: Managing Multiuser Databases 9-1 KROENKE.
Managing Multi-User Databases. Mutli-User Issues n Concurrency Control n Database Reliability n Database Security n Database Administration.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 Transations.
1 Advanced Database Concepts Transaction Management and Concurrency Control.
Module 11: Managing Transactions and Locks
Transaction Management and Concurrent Control
9 1 Chapter 9_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
10 Transaction Management and Concurrency Control MIS 304 Winter 2005.
©Bob Godfrey, 2002, 2005 Lecture 17: Transaction Integrity and Concurrency BSA206 Database Management Systems.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
10 1 Chapter 10 - A Transaction Management Database Systems: Design, Implementation, and Management, Rob and Coronel.
Module 14: Managing Transactions and Locks. Overview Introducing Transactions and Locks Managing Transactions Understanding SQL Server Locking Architecture.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Nine: Managing Multiuser Databases.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Locks, Blocks & Isolation Oh My!. About Me Keith Tate Data Professional for over 14 Years MCITP in both DBA and Dev tracks
Transactions and Concurrency Control. 2 What is a Transaction?  Any action that reads from and/or writes to a database may consist of  Simple SELECT.
9 1 Chapter 9 Transaction Management and Concurrency Control Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Transaction Management and Concurrency Control
Database Administration
Chapter 9 Managing Multi-User Databases
Multi-User Databases Chapter 9.
Database Processing: David M. Kroenke’s Chapter Nine: Part One
Chapter 10 Transaction Management and Concurrency Control
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Transactions and Concurrency
Database Administration
Presentation transcript:

Database Administration Part 1 Chapter Six CSCI260 Database Applications

2 Chapter Objectives Understand the need for and importance of database administration Understand the need for and importance of database administration Learn different ways of processing a database Learn different ways of processing a database Understand the need for concurrency control, security, and backup and recovery Understand the need for concurrency control, security, and backup and recovery Learn typical problems that can occur when multiple users process a database concurrently Learn typical problems that can occur when multiple users process a database concurrently Understand the use of locking and the problem of deadlock Understand the use of locking and the problem of deadlock Understand the use of locking and the problem of deadlock Understand the use of locking and the problem of deadlock

3 Chapter Objectives (continued) Learn the difference between optimistic and pessimistic locking Learn the difference between optimistic and pessimistic locking Know the meaning of ACID transaction Know the meaning of ACID transaction Learn the four 1992 ANSI standard isolation levels Learn the four 1992 ANSI standard isolation levels Understand the need for security and learn a generalized model of database security Understand the need for security and learn a generalized model of database security Know the difference between DBMS and application security Know the difference between DBMS and application security Know the difference between recovery via reprocessing and recovery via rollback/rollforward Know the difference between recovery via reprocessing and recovery via rollback/rollforward

4 Chapter Objectives (continued) Understand the nature of the tasks required for recovery using rollback/rollforward Understand the nature of the tasks required for recovery using rollback/rollforward Know basic administrative and managerial DBA functions Know basic administrative and managerial DBA functions

5 Database Processing Environment A database processing environment is complicated and multi-faceted A database processing environment is complicated and multi-faceted –Multiple users –Multiple queries –Multiple forms –Multiple reports –Multiple application programs

6 Processing Constraints Enforcing referential integrity Enforcing referential integrity Cascading deletion Cascading deletion Cascading modifications Cascading modifications Data type constraints Data type constraints Data size constraints Data size constraints Data value constraints Data value constraints Null constraints Null constraints Uniqueness constraints Uniqueness constraints

7 Internet Application Processing Internet Application Processing is more complicated than traditional application processing Internet Application Processing is more complicated than traditional application processing Specifically, with Internet Application Processing … Specifically, with Internet Application Processing … –The network becomes an integral part of the application

8 The Database Processing Environment

9 Stored Procedures A stored procedure is a module similar to subroutine or function that performs database actions A stored procedure is a module similar to subroutine or function that performs database actions –Stored in the database itself –Can pass it parameters, receive results –Written in PL/SQL (oracle), TRANSACT-SQL (SQL Server)

10 Stored Procedures

11 Stored Procedures

12 Triggers A trigger is a stored procedure that is automatically invoked by the DBMS when a specified activity occurs A trigger is a stored procedure that is automatically invoked by the DBMS when a specified activity occurs –BEFORE, AFTER and INSTEAD OF

13 Control, Security and Reliability Possible to have many database functions occurring at the same time Possible to have many database functions occurring at the same time Three necessary database administration functions Three necessary database administration functions –Concurrency control –Security –Backup and Recovery

14 Concurrency Control Concurrency control ensures that one user’s actions do not adversely impact another user’s actions Concurrency control ensures that one user’s actions do not adversely impact another user’s actions At the core of concurrency is accessibility. In one extreme, data becomes inaccessible once a user touches the data. This ensures that data that is being considered for update is not shown. In the other extreme, data is always readable. The data is even readable when it is locked for update. At the core of concurrency is accessibility. In one extreme, data becomes inaccessible once a user touches the data. This ensures that data that is being considered for update is not shown. In the other extreme, data is always readable. The data is even readable when it is locked for update.

15 Concurrency Control (continued) Interdependency Interdependency –Changes required by one user may impact others Concurrency Concurrency –People or applications may try to update the same information at the same time Record retention Record retention –When information should be discarded

16 Need for Atomic Transactions A database operation typically involves several transactions. These transactions are atomic and are sometimes called logical units of work (LUW). A database operation typically involves several transactions. These transactions are atomic and are sometimes called logical units of work (LUW). Before an operation is committed to the database, all LUWs must successfully complete. If one or more LUW is unsuccessful, a rollback is performed and no changes are saved to the database. Before an operation is committed to the database, all LUWs must successfully complete. If one or more LUW is unsuccessful, a rollback is performed and no changes are saved to the database.

17 Need for Atomic Transactions Example: Sequence required when recording new order. Example: Sequence required when recording new order. –1. Change the customer record, increasing value of amount owed. –2. Change the salesperson record, increasing the value of Commission Due. –3. Insert new order record into the database. If last one fails, roll back all three

18

19

20 Lost Update Problem If two or more users are attempting to update the same piece of data at the same time, it is possible that one update may overwrite another update. If two or more users are attempting to update the same piece of data at the same time, it is possible that one update may overwrite another update.

21 Concurrent Processing Example

22 Concurrent Processing Problem

23 Concurrency Issues Concurrency issues common – have standardized names… Concurrency issues common – have standardized names… Dirty reads Dirty reads –The transaction reads a changed record that has not been committed to the database –Example: One transaction reads row changed by a second transaction. Second transaction later cancels (rollsback) its changes

24 Concurrency Issues Inconsistent reads/Non-repeatable read Inconsistent reads/Non-repeatable read –The transaction re-reads a data set and finds that the data has changed Phantom reads Phantom reads –The transaction re-reads a data set and finds that a new record has been added Fix some of these issues with Resource Locking

25 Resource Locking To avoid concurrency issues, resource locking will disallow transactions from reading, modifying, and/or writing to a data set that has been “locked” To avoid concurrency issues, resource locking will disallow transactions from reading, modifying, and/or writing to a data set that has been “locked” Prevent sharing of data Prevent sharing of data Transactions can use a lock command Transactions can use a lock command

26

27 Implicit versus Explicit Resource Locking Implicit locks are issued automatically by the DBMS based on an activity Implicit locks are issued automatically by the DBMS based on an activity Explicit locks are issued by users requesting exclusive rights to the data Explicit locks are issued by users requesting exclusive rights to the data

28 Lock Granularity Size of lock has different impacts Size of lock has different impacts Large Granularity lock Large Granularity lock –e.g. lock entire table –easy for DBMS to administer –Frequently cause conflicts Smaller Granularity lock Smaller Granularity lock –E.g. lock row –Harder for DBMS to administer (lots of details) –Fewer conflicts

29 Lock Types Exclusive Lock Exclusive Lock –Locks an item from access of any type –No other transaction can read or change the data Shared lock Shared lock –Locks an item from being changed –Item can still be read, just can’t alter it

30 Serializable Transactions (Two-Phased Locking) Two-phased locking, whereby locks are obtained as they are needed Two-phased locking, whereby locks are obtained as they are needed –A growing phase, whereby the transaction continues to request additional locks –A shrinking phase, whereby the transaction begins to release the locks

31 Serializable Transactions Example Order-entry transaction that involves processing data in CUSTOMER, SALESPERSON and ORDER tables. Order-entry transaction that involves processing data in CUSTOMER, SALESPERSON and ORDER tables. –Transaction issues locks on all three tables –Makes all the database changes –Releases all its locks

32 Deadlock As a transaction begins to lock resources, it may have to wait for a particular resource to be released by another transaction As a transaction begins to lock resources, it may have to wait for a particular resource to be released by another transaction On occasions, two transactions may indefinitely wait on each another to release resources. This condition is known as a deadlock or a deadly embrace On occasions, two transactions may indefinitely wait on each another to release resources. This condition is known as a deadlock or a deadly embrace

33 Deadlock Example User A wants to order some paper User A wants to order some paper –If she can get the paper, she wants to order pencils User B wants to order some pencils. User B wants to order some pencils. –If he can get the pencils, he will order paper

34

35 Optimistic versus Pessimistic Locking Optimistic OptimisticLocking –Read data –Process transaction –Issue update –Look for conflict –If conflict occurred, rollback and repeat –Else commit Pessimistic PessimisticLocking –Lock required resources –Read data –Process transaction –Issue commit –Release locks

36

37

38 Consistent Transactions Consistent transactions are often referred to by the acronym ACID Consistent transactions are often referred to by the acronym ACID –Atomic –Consistent –Isolated –Durable

39 ACID: Atomic A transaction consists of a series of steps. Each step must be successful for the transaction to be saved A transaction consists of a series of steps. Each step must be successful for the transaction to be saved This ensures that the transaction completes everything it intended to do before saving the changes This ensures that the transaction completes everything it intended to do before saving the changes

40 ACID: Consistent No other transactions are permitted on the records until the current transaction finishes No other transactions are permitted on the records until the current transaction finishes This ensures that the transaction integrity has statement level consistency among all records This ensures that the transaction integrity has statement level consistency among all records

41 ACID: Consistent Example: Example: UPDATE CUSTOMER SET AreaCode = ‘425’ WHEREZipCode = ‘14048’; UPDATE CUSTOMER SET AreaCode = ‘425’ WHEREZipCode = ‘14048’; CUSTOMER table has 500,000 rows. 500 match above zipcode CUSTOMER table has 500,000 rows. 500 match above zipcode May take awhile to find them all – can other transactions update during this? May take awhile to find them all – can other transactions update during this? Statement level consistency – update will apply to the set of rows as they existed at the time the SQL Statement started Statement level consistency – update will apply to the set of rows as they existed at the time the SQL Statement started

42 ACID: Isolation Within multiuser environments, different transactions may be operating on the same data Within multiuser environments, different transactions may be operating on the same data As such, the sequencing of uncommitted updates, rollbacks, and commits continuously change the data content As such, the sequencing of uncommitted updates, rollbacks, and commits continuously change the data content

43 ACID: Durable A durable transaction is one in which all committed changes are permanent A durable transaction is one in which all committed changes are permanent Even in the case of failure Even in the case of failure

ANSI SQL Isolation levels