Docsity

Database Transactions: Understanding the Logical Unit of Work, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Database Transactions: Understanding the Logical Unit of Work and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

What is a Transaction?

AKA [atomic transaction].

What is a Transaction?

AKA [atomic transaction]. logical unit of work: Do or Do Not. App designer(you) creates an indivisible unit of db actions.

What is a Transaction?

AKA [atomic transaction]. logical unit of work: Do or Do Not. App designer(you) creates an indivisible unit of db actions. A transaction can have Accesses and Modifications.

The Transaction Process

  1. Open a connection to a database
  2. Start a transaction.
  3. Do a list of SELECTs and or UPDATEs.
  4. Close the transaction by COMMIT; or ROLLBACK;
  5. Close the database connection.

The Transaction Process

  1. Open a connection to a database
  2. Start a transaction.
  3. Do a list of SELECTs and or UPDATEs.
  4. Close the transaction by COMMIT; or ROLLBACK;
  5. Close the database connection.

The Transaction Process

  1. Open a connection to a database
  2. Start a transaction.
  3. Do a list of SELECTs and or UPDATEs.
  4. Close the transaction by COMMIT; or ROLLBACK;
  5. Close the database connection.

Commit

Commit = yes, save change. One way street Like when the pig becomes bacon.

Example of a Transaction

START TRANSACTION;

INSERT INTO users (name, pass) VALUES (’alan’, PASSWORD(’ferret’) ) ; yyy COMMIT; Another Example: BEGIN WORK; INSERT INTO users (name, pass) VALUES (’alan’, PASSWORD(’ferret’) ) ; yyy ROLLBACK;

MySQL Transaction Support

Use the InnoDB or BDB engines.

Idea behind DB with Transaction Management

Atomicity

one complete unit smallest no reduce property: updates by transaction are all used or not

Consistency

db should be consistent previous T db should be consistent after T property: after applying ACID T db is consistent.

Durable

Transaction fails ACID == BAD property: commited transaction means all updates are permanent.

Locks

Types: read,write sizes: database, table, row, column, field, index, system resource.