Files
G4G0-1/Semester 2/Database Systems/Week 3/Week 3 Database Systems.md

47 lines
2.0 KiB
Markdown

# Online Transaction Processing Systems
Systems that need real time support for querying and updating of databases by one or more concurrent users.
Data is updated in real time frequently, but must maintain correctness of the database state regardless of hardware and software failures, and multiple users accessing said data.
## Examples of OLTPs
- Banking / Credit Card processing systems
- Transport reservation systems
- Trading / Brokerage systems
- E-commerce
### Example 1
- Two students registering for the same class ( Student Enrolment Database )
NumEnroled = 39
MaxEnroled = 40
If two students attempt to enrol at the same time, NumEnroled = 41, which is in an inconsistent state, violating semantic constraints, when processing requests from multiple concurrent users.
### Example 2
- Two people attempt to withdraw from two different ATMs in a joint account
- Person A withdraws £100 at ATM 1
- Person B withdraws £50 from ATM 2
- Initial balance £400
Final balance should be £250 no matter who withdraws first.
However, if they withdraw at the same time, the final balance would be £300 OR £350, depending on various attributes of the ATMs ( physical location, processing speed, current load, etc. ), as £400 total balance would be reported to both ATMs
## Challenges of OLTP
Although the AQL code is written correctly, the database may be in an inconsistent state after processing transactions due to failures of hard / software / multiple users accessing the db.
A consistent state of the database means it satisfied all the constraints specified in the schema ( overall description of the database: pk, fk, referential integrity, etc. ), and any other constraints on the database that should hold ( eg. semantic constraints. )
# Transaction
An action / series of actions, carried out by a single user or application program that reads or updates the contents of the database.
- A transaction is treated as a logical unit of work on the database. This may be
- An entire program
- Part of a program
- A single statement