220 likes | 383 Vues
Data and Database Administration. Transaction Management Concurrency Control Database Security. Learning Objectives. Describe the importance of data and database management Describe database transactions are and how they are managed
E N D
Data and Database Administration Transaction Management Concurrency Control Database Security
Learning Objectives • Describe the importance of data and database management • Describe database transactions are and how they are managed • Explain concurrency control and locking methods and what role they have in ensuring database integrity • Describe database backup and recovery and the role they play in database integrity • Describe the role and responsibilities of a Database Administrator and tools used to perform required tasks • Apply transaction management principles to solve problems
Traditional Administration Definitions Data Administration: • High-level function • Policy & Procedure Planning • DBMS independent • Strategic Database Administration: • Technical function • Policy &Procedure Enforcement • DBMS dependent • Tactical
What is a database transaction? • Logical unit of work in your database • Succeeds / fails as a whole • Works independently of other “units of work” • Doesn’t know about anything else but itself. • Whether you realize it or not, everything’s a transaction. When you want to change the
Transaction ACID Properties • Atomic • Transaction cannot be subdivided. Logical unit of work. • Consistent • Constraints don’t change from before transaction to after transaction • Isolated • Database changes not revealed to users until after transaction has completed • Durable • Database changes are permanent once committed.
Transaction FFCU Demo Demonstration of the ACID principles.
Transactions on SQL server • SET IMPLICIT_TRANSACTIONS ON • DBA responsible for ending the transaction using COMMIT/ ROLLBACK. • Great way to have an “Undo” feature while working interactively • Make sure you commit all transactions and check @@TRANCOUNT • SET IMPLICIT_TRANSACTIONS OFF • Default behavior; used in stored procedures and database logic • DBA must figure out when to COMMIT / ROLLBACK • @@ROWCOUNT inspection is a common approach
Transaction FFCU Demo Implicit and explicit transactions, and transaction-safe coding.
Concurrency Control • Problem–in a multiuser environment, simultaneous access to data can result in interference and data loss • Solution–Concurrency Control • The process of managing simultaneous operations against a database so that data integrity is maintained and the operations do not interfere with each other in a multi-user environment
Lost update (no concurrency control in effect) Simultaneous access causes updates to cancel each other A similar problem is the inconsistent read problem
Concurrency Control Techniques • Serializability • Finish one transaction before starting another • Locking Mechanisms • The most common way of achieving serialization • Data that is retrieved for the purpose of updating is locked for the updater • No other user can perform update until unlocked
Updates with locking (concurrency control) This prevents the lost update problem
Locking Mechanisms • Locking level: • Database–used during database updates • Table–used for bulk updates • Block or page–very commonly used • Record–only requested row; fairly commonly used • Field–requires significant overhead; impractical • Types of locks: • Shared lock–Read but no update permitted. Used when just reading to prevent another user from placing an exclusive lock on the record • Exclusive lock–No access permitted. Used when preparing to update
Versioning - Example Better performance than locking
Database Security • Database Security: Protection of the data against accidental or intentional loss, destruction, or misuse • Increased difficulty due to Internet access and client/server technologies • More exposure == Greater Risk!
Security Authorization matrix These are implemented through the external model (views / sp’s) and controlling accessing to database objects with GRANT/REVOKE
Database Backup – the audit trail From the backup and logs, databases can be restored in case of damage or loss
Basic recovery techniques - Rollback Like and “Undo” button for the Database
Basic recovery techniques - Rollforward Point-in-time restore for the Database
Advanced Database Concepts Questions?