1 Chapter 10 Protecting Data Integrity in a Multiuser Environment.

Slides:



Advertisements
Similar presentations
Optimistic Methods for Concurrency Control By : H.T. Kung & John T. Robinson Presenters: Munawer Saeed.
Advertisements

Manipulating Data Schedule: Timing Topic 60 minutes Lecture
What is a Transaction? A transaction is a logical logic of work A transaction may have one of two outcomes –When a transaction completes successfully,
Allowing Multi-user Access Grant – GRANT ON TO |WITH GRANT OPTION | –GRANT TO | WITH ADMIN OPTION| – can be PUBLIC or a role – can be ALL Revoke – REVOKE.
1 Data Concurrency David Konopnicki 1997 Revised by Mordo Shalom 2004.
Data and Database Administration Chapter 12. Outline What is Concurrency Control? Background Serializability  Locking mechanisms.
1 Chapter 12 Working With Access 2000 on the Internet.
Database Administration Chapter Six DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
1 7 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 7 DBMS Functions.
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
Using Objects and Properties
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
DBMS Functions Data, Storage, Retrieval, and Update
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 8-1 COS 346 Day 18.
Concepts of Database Management Sixth Edition
9 Chapter 9 Transaction Management and Concurrency Control Hachim Haddouti.
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Database Administration Part 1 Chapter Six CSCI260 Database Applications.
Functions of a Database Management System. Functions of a DBMS C.J. Date n Indexing n Views n Security n Integrity n Concurrency n Backup/Recovery n Design.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Management and Concurrency Control
MS Access Advanced Instructor: Vicki Weidler Assistant:
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
© 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 CHAPTER 11: DATA AND DATABASE ADMINISTRATION Modern Database Management 11 th Edition Jeffrey.
Concepts of Database Management, Fifth Edition
Chapter 4 The Relational Model 3: Advanced Topics Concepts of Database Management Seventh Edition.
Recovery & Concurrency Control. What is a Transaction?  A transaction is a logical unit of work that must be either entirely completed or aborted. 
Allowing Multi-user Access Grant – GRANT ON TO – |WITH GRANT OPTION / WITH ADMIN OPTION| – can be PUBLIC or a role – can be all Revoke – REVOKE ON FROM.
Database Management System Module 5 DeSiaMorewww.desiamore.com/ifm1.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
Unit 9 Transaction Processing. Key Concepts Distributed databases and DDBMS Distributed database advantages. Distributed database disadvantages Using.
1 IRU Concurrency, Reliability and Integrity issues Geoff Leese October 2007 updated August 2008, October 2009.
1 IT420: Database Management and Organization Session Control Managing Multi-user Databases 24 March 2006 Adina Crăiniceanu
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
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.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
MBA 664 Database Management Dave Salisbury ( )
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 Transations.
1 Intro stored procedures Declaring parameters Using in a sproc Intro to transactions Concurrency control & recovery States of transactions Desirable.
Introduction to Distributed Databases Yiwei Wu. Introduction A distributed database is a database in which portions of the database are stored on multiple.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
1 Advanced Database Concepts Transaction Management and Concurrency Control.
Module 11: Managing Transactions and Locks
9 1 Chapter 9_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
NOEA/IT - FEN: Databases/Transactions1 Transactions ACID Concurrency Control.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
©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.
18 September 2008CIS 340 # 1 Last Covered (almost)(almost) Variety of middleware mechanisms Gain? Enable n-tier architectures while not necessarily using.
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
Copyright © 2016 Pearson Education, Inc. CHAPTER 12: DATA AND DATABASE ADMINISTRATION Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman,
Transaction Management and Concurrency Control
Functions of a Database Management System
Database Processing: David M. Kroenke’s Chapter Nine: Part One
Chapter 10 Transaction Management and Concurrency Control
On transactions, and Atomic Operations
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Transactions and Concurrency
Database Administration
DB Concurrency ITEC 340 Database I Dr. Ian Barland
Transactions, Properties of Transactions
Presentation transcript:

1 Chapter 10 Protecting Data Integrity in a Multiuser Environment

10 Chapter Objectives Develop code that implements database transactions Develop code that commits and rolls back transactions Identify the types of problems that occur when multiple users access a database concurrently

10 Chapter Objectives Implement database, recordset, page-level, and record-level locking strategies Develop error-handling procedures that support concurrent use of a database Replicate and synchronize replicas and partial replicas of a database

10 Using Transactions to Protect Against System Failure Transaction  Logical unit of work  Each unit of work comprises one or more physical database operations When a transaction completes successfully, changes that the transaction made to the database are committed to the database

10 Using Transactions to Protect Against System Failure Whenever a transaction aborts, changes that it made to the database before aborting are not committed to the database  Changes are rolled back  Database fields that contain changes return to their original state

10 Transaction Processing in VBA Three methods of the Connection object to define the beginning or end of a transaction in VBA:  BeginTrans  Denotes the beginning of the transaction  CommitTrans  Denotes the end of a successful transaction  Rollback Trans  Denotes the end of an unsuccessful transaction

10 Additional Transaction Features and Caveats UseTransaction property  When set to Yes, a transaction is automatically defined for the query  Therefore, BeginTrans and CommitTrans methods are unnecessary FailOnError property  When set to Yes, the query results are automatically rolled back when the first error occurs

10 Additional Transaction Features and Caveats Figure 10-1 Setting the Use Transaction and Fail On Error properties in query Design view

10 Additional Transaction Features and Caveats Access supports a maximum of five levels of nested transactions When one transaction is nested inside another, commitments of transactions are temporary until the final CommitTrans method executes  If that method does not execute or the corresponding RollbackTrans method executes, all nested transactions are rolled back

10 Additional Transaction Features and Caveats Connection object  Controls a transaction Recordsets that use a particular connection are rolled back when the RollbackTrans method is applied to the Connection object When data are updated through bound forms, Access developers have little control over the definition of a transaction  Access controls the updates

10 Solving Concurrent Processing Problems Concurrent transactions  Transactions that overlap Inconsistent analysis  Type of concurrency issue Locking mechanisms  Prevent more than one transaction at a time from modifying a data object

10 Solving Concurrent Processing Problems Granularity  Level of locking Write lock  Allows other users to read but not update the locked records  Prevents the lost update problem, but not prevent the inconsistent analysis problem

10 Solving Concurrent Processing Problems Read lock  Prevents other users from reading or writing locked records  Prevents both the inconsistent analysis problem and the lost update problem Pessimistic locking  Locks a page or record as soon as the first field in the record is changed and releases a lock after the record is written

10 Solving Concurrent Processing Problems Optimistic locking  Locks a page or record when the Update method is encountered in VBA and releases the lock after record is written Isolation level  Indicates the degree to which the transaction should be independent of other transactions Dirty read  Prevented by specifying that transaction should not read changes made by another transaction until the other transaction is complete

10 Locking Records at the Database Level You can lock the entire database through the Open window Figure 10-2 Opening a database in Exclusive made

10 Locking Records at the Database Level You can lock databases through startup command lines and VBA code Figure 10-3 Record locking defaults within Advanced tab of Options dialog box

10 Locking Records at the Database Level Figure 10-4 Opening a database in Exclusive mode through a shortcut

10 Locking Records at the Database Level Mode property of the Connection object  Used to specify whether other users can access the database  When set to the intrinsic constant adModeShareExclusive, other users cannot open a connection to the database

10 Locking Records at the Database Level Table 10-1 Legal values for the Mode property

10 Setting the Locking Characteristics of Bound Forms RecordsLocks property of a form and Advanced tab of the Options dialog box are used to set locking characteristics of bound forms Table 10-2 Setting the locking characteristics of bound forms

10 Setting the Locking Characteristics of Bound Forms Recordset-level locks  Specified by setting the RecordLocks property to All Records in the form property sheet or to 1 in VBA Edited Record option  Locks a record (or page) as soon as a user begins to change the value of a field No Locks option  Does not lock the record until all of the changes have been made

10 Record-Level Locking Techniques in VBA Locktype property  Used to adjust locking strategy of recordsets other than those associated with bound forms  adLockPessimistic  Employs pessimistic locking  adLockOptimistic  Employs optimistic locking

10 The CursorType Property CursorType property of a recordset object  Indicates how to respond when others make changes Values of CursorType relevant for Jet Engine  adOpenStatic indicates that once recordset is created, it should not reflect changes, new records, or deletions made by other users  adOpenKeyset indicates that the transaction cannot view the results of another transaction until the other transaction is committed

10 The IsolationLevel Property IsolationLevel property  Used to control how Access behaves in a multiple-user environment  Indicates how you should respond when others make changes  Property of a Connection object

10 The IsolationLevel Property Specifies when recordsets can view changes by users  If it is set to adXactReadUncommitted:  Recordset can view changes by others before they are committed in a transaction  A dirty read is possible  adXactReadCommitted  Indicates that the transaction cannot view the results of another transaction until the other transaction is committed

10 The IsolationLevel Property Table 10-3 IsolationLevel values and descriptions

10 Problems with Locking Deadlock  Situation where each transaction is waiting for the other to release a locked resource and neither transaction can finish Update Retry Interval  The time, in milliseconds, that Access waits before trying to obtain the record again Number of Update Retries  Number of times Access will attempt to obtain a record

10 Handling Concurrency Errors If an error handler detects a locked database, recordset, or record, the error-handling routine typically waits and then repeats the statement through the use of the Resume statement SQLState property of an Error object  Returns a value that identifies the error according to the ANSI SQL standard

10 Handling Concurrency Errors Table 10-4 Commonly used values of SQL State

10 Handling Concurrency Errors Number property of an Error object  Returns a long integer that is determined by the database provider and the connection Status property of a recordset object  May be consulted to gather information about the success or failure of an operation

10 Handling Concurrency Errors Table 10-5 Values of the recordset Status property

10 Handling Concurrency Errors Table 10-5 Values of the recordset Status property (continued)

10 Database Replication Database replication  Creates copies of all or part of a database  Each copy cab reside on a different computer Synchronization  A process used to periodically distribute updates from one copy to other copies of the database

10 An Overview of Replication and Synchronization Steps Design Master  Copy of the database that can propagate structural changes Two issues must be resolved during the process of creating the Design Master:  The design of the database should be analyzed to determine whether it adequately supports replication  You must determine which objects will be replicated

10 An Overview of Replication and Synchronization Steps Design Master replica set  Consists of databases that share the same Design Master database Types of replicas:  Complete replica  Contains all of the data from replicable tables  Partial replica  Contains only the rows that meet a particular criterion

10 An Overview of Replication and Synchronization Steps Types of views replicas can have:  Global replicas  Can be used to create other replicas and can be synchronized with any replica  Can create and then serve as a synchronization hub for local replicas  Local replicas  Can create only other local replicas and must be synchronized with the global replica that was used to create it

10 An Overview of Replication and Synchronization Steps Replicas created from a particular global replica, directly or transitively through a local replica, define a replica set Figure 10-6 Replica sets

10 An Overview of Replication and Synchronization Steps During synchronization, a conflict occurs when:  The same record and column in two different replicas have been updated  Two records share the same primary key and when one replica deletes a record that has a referential integrity relationship with a record in another replica

10 Replication Within VBA Microsoft Jet and Replication Object Library (JRO)  Contains object that support methods that perform activities similar to the activities carried out when you replicate and synchronize through the menus  Must be checked in the References window before you can use the replication objects

10 Replication Within VBA Table 10-6 Replication objects and methods

10 Replication Within VBA You can create partial replicas by using the CreateReplica, Append, and PopulatePartial methods  Partial replicas are not populated through the CreateReplica method  PopulatePartial method adds data to the replica

10 Chapter Summary Features such as transactions, locking, and replication help Access developers prepare an application to function in complex environments Notion of a transaction  Controls how concurrent access occurs Transaction  Logical grouping of database operations that define a unit of work

10 Chapter Summary One way that transactions control database processing is by defining when changes affected by the transaction may actually be applied to the database CommitTrans and RollbackTrans connection methods  Handle problems with committing a transaction’s effects to a database

10 Chapter Summary In Access, to control problems caused by the actions of multiple users, transactions use a locking scheme  Pessimistic locking  Locks a record as soon as it is edited  Optimistic locking  Locks a record when it is about to be updated

10 Chapter Summary Replication  Used when more than one site needs access to an application, but network access is not available or desired  Replica  Copy of an application  Partial replica  Filters a table, so that the records in the replica are a subset of the original table’s records

10 Chapter Summary Synchronization of replicas  Process where updates made in one replica are propagated to other replicas Replication difficulties occur when two replicas modify the same column and record A conflict resolution function is used to determine whether the correct value was placed in the database