1 / 44

Database Administration Part 1

CSCI260 Database Applications. Database Administration Part 1. Chapter Six. Chapter Objectives. Understand the need for and importance of database administration Learn different ways of processing a database Understand the need for concurrency control, security, and backup and recovery

dava
Download Presentation

Database Administration Part 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCI260 Database Applications Database AdministrationPart 1 Chapter Six

  2. Chapter Objectives • Understand the need for and importance of database administration • Learn different ways of processing a database • Understand the need for concurrency control, security, and backup and recovery • 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

  3. Chapter Objectives (continued) • Learn the difference between optimistic and pessimistic locking • Know the meaning of ACID transaction • Learn the four 1992 ANSI standard isolation levels • 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 recovery via reprocessing and recovery via rollback/rollforward

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

  5. Database Processing Environment • 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 • Cascading deletion • Cascading modifications • Data type constraints • Data size constraints • Data value constraints • Null constraints • Uniqueness constraints

  7. Internet Application Processing • Internet Application Processing is more complicated than traditional 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 • 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 • BEFORE, AFTER and INSTEAD OF

  13. Control, Security and Reliability • Possible to have many database functions occurring at the same time • 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 • 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 • Changes required by one user may impact others • Concurrency • People or applications may try to update the same information at the same time • 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). • 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. • 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. 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.

  19. Concurrent Processing Example

  20. Concurrent Processing Problem

  21. Concurrency Issues • Concurrency issues common – have standardized names… • 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

  22. Concurrency Issues • Inconsistent reads/Non-repeatable read • The transaction re-reads a data set and finds that the data has changed • 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

  23. 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” • Prevent sharing of data • Transactions can use a lock command

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

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

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

  27. Serializable Transactions (Two-Phased Locking) • 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

  28. Serializable Transactions Example • 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

  29. Deadlock • 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

  30. Deadlock Example • 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. • If he can get the pencils, he will order paper

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

  32. Consistent Transactions • Consistent transactions are often referred to by the acronym ACID • Atomic • Consistent • Isolated • Durable

  33. ACID: Atomic • 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

  34. ACID: Consistent • 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

  35. ACID: Consistent • Example: • UPDATE CUSTOMERSET AreaCode = ‘425’WHERE ZipCode = ‘14048’; • CUSTOMER table has 500,000 rows. 500 match above zipcode • 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

  36. ACID: Isolation • 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

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

  38. 1992 ANSI SQL Isolation levels

More Related