Transactions

655 views

Published on

Database transactions

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
655
On SlideShare
0
From Embeds
0
Number of Embeds
145
Actions
Shares
0
Downloads
29
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transactions

  1. 1. Transactions CIS-182
  2. 2. Transactions • Transaction is an action that occurs – Student enrolls in class – Often associated to movement • When enroll, student ID is “moved” to requested enrollment list • In a database, data moving from one place to another, and ensuring proper and complete movement, is a transaction
  3. 3. Database Transactions • Provides method for canceling an operation • Can restore rows, columns to original state in event of error or business logic failure • Use when changes will either be committed or discarded in entirety
  4. 4. Transaction Types • Explicit: Define where the transaction begins, ends • Implicit: When data movement occurs without a specific beginning, a transaction is implied • Goal is to ensure that database is always correct – Movement (storage) is successful; or – Movement is cancelled – No partial movement is allowed
  5. 5. ACID • ACID describes conditions that a valid transaction must meet • Atomic: All steps in an operation are treated as one piece of work – All steps succeed or no steps succeed • Consistent: Outcome is always predictable – An operation will always work or never work
  6. 6. ACID – 2 • Isolated: If multiple transactions occur, data is never available in an intermediate state (partial change) • Durable: Once finished, all changes are complete and changes can only be done by another transaction/unit of work
  7. 7. Transaction Log • Tracks each action in the database – Provides a record of what happened in sequential order • Used by SQL Server to ensure that ACID requirements are met • Also used in event of failure to recreate database since last backup – Backups create record of database contents at specific points in time
  8. 8. CRUD • Four operations affecting data • Create (or INSERT) an entry • Retrieve (or SELECT) an entry • Update an entry • Delete an entry
  9. 9. CIS-182 Transactions • Using implied transactions • When executing INSERT, UPDATE, DELETE, if any part of the statement fails, the change to the row is not saved to disk – In INSERT, if one value doesn’t satisfy a CHECK constraint, no values are added to the table – When UPDATE, if referential integrity is violated the change won’t be saved

×