data and database administration

22
Data and Database Administration Transaction Management Concurrency Control Database Security

Upload: bisa

Post on 11-Feb-2016

69 views

Category:

Documents


0 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Data and Database Administration

Data and Database Administration

Transaction ManagementConcurrency ControlDatabase Security

Page 2: Data and Database Administration

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

Page 3: Data and Database Administration

Traditional Administration Definitions

Data Administration: • High-level function• Policy & Procedure

Planning• DBMS independent• Strategic

Database Administration: • Technical function• Policy &Procedure

Enforcement• DBMS dependent• Tactical

Page 4: Data and Database Administration

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

Page 5: Data and Database Administration

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.

Page 6: Data and Database Administration

Transaction FFCU Demo

Demonstration of the ACID principles.

Page 7: Data and Database Administration

Concept Example of concept

Transaction Jimmy “do you have a candy bar?” Sally “yes”, then the exchange of $1 for a candy bar between Jimmy and Sally takes place.

Not-Atomic Jimmy gives Sally $1; Sally pockets $1, but keeps the candy bar. Jimmy cries.

Atomic (commit)

The exchange between Jimmy and Sally happens as one unit of work. They exchange money and candy together.

Atomic (rollback)

The exchange between Jimmy and Sally happens as one unit of work. They exchange money and candy at the exact same time, but Jimmy slips Sally a counterfeit $1 bill. Sally demands and receives her candy back, since there was not a valid exchange.

Consistent Before transaction: Jimmy=$1, Sally=Candy Bar, After: Jimmy=Candy Bar, Sally=$1

Not-Consistent Jimmy gives Sally $1, Sally pockets $1 and eats ½ the candy bar in front of Jimmy. Sally grins and laughs, then gives him ½ the candy bar.

Isolated Jimmy and Tommy both ask to buy a candy bar at the same time. Sally tells Tommy “hang on a second; I’ll be right with you.” Sally transacts with Jimmy, and then turns to Tommy and say’s “sorry I just sold out.” Tommy doesn’t know Jimmy got the candy bar.

Not-Isolated Jimmy and Tommy both ask to buy the candy bar at the same time. Sally tells both of them she has a candy bar. She sells it to Jimmy for $1 with Tommy knowing the transaction took place. Tommy knows what Sally did and his feelings are hurt. Tommy cries.

Durable The transaction takes place successfully between Jimmy and Sally. Jimmy decides he no longer wants the candy bar, but Sally says “Sorry, all sales are final!” Jimmy must now try to recoup is $1 with Tommy.

Not-Durable The transaction takes place successfully between Jimmy and Sally. Jimmy no longer wants the candy bar but Sally says “Sorry all sales are final.” Jimmy tells Sally’s Mother and Father and her parents force her to refund the transaction.

Page 8: Data and Database Administration

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

Page 9: Data and Database Administration

Transaction FFCU Demo

Implicit and explicit transactions, and transaction-safe coding.

Page 10: Data and Database Administration

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

Page 11: Data and Database Administration

Lost update (no concurrency control in effect)

Simultaneous access causes updates to cancel each otherA similar problem is the inconsistent readinconsistent read problem

Page 12: Data and Database Administration

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

Page 13: Data and Database Administration

Updates with locking (concurrency control)

This prevents the lost update problem

Page 14: Data and Database Administration

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

Page 15: Data and Database Administration

Better performance than locking

Versioning - Example

Page 16: Data and Database Administration

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!

Page 17: Data and Database Administration

Possible locations of data security threats

Page 18: Data and Database Administration

Security Authorization matrix

These are implemented through the external model (views / sp’s) and controlling accessing to database objects with GRANT/REVOKE

Page 19: Data and Database Administration

From the backup and logs, databases can be restored in case of damage or loss

Database Backup – the audit trail

Page 20: Data and Database Administration

Basic recovery techniques - Rollback

Like and “Undo” button for the Database

Page 21: Data and Database Administration

Basic recovery techniques - Rollforward

Point-in-time restore for the Database

Page 22: Data and Database Administration

Advanced Database Concepts

Questions?