1. The document discusses transactions in SQL and PHP/PDO. It provides examples of running concurrent transactions that update the same table from two separate terminals.
2. It then covers transaction concepts like atomicity, consistency, isolation, and durability. It demonstrates how to start a transaction, insert and select data, and either commit or roll back the transaction in PHP/PDO.
3. The transaction is stored in the database until it is either committed or rolled back. Stress testing with JMeter is suggested to simulate high user loads on database resources.
2. Recap: Transactions
2 Transactions running concurrently In 2 separate terminals
1 2
begin work;
Update mytest set Update mytest set val1 =
val1 = “Transaction “another update” where
update” where val2 =
“adsf”; val2 = “adsf”;
Commit;
Waits for transaction 1 to commit
4. PHP
Useful easy to hack together server side language
Useful- but don’t stress out trying to get to 100% understand it in this
module
5. Testing PHP
• Turn on Apache and MySQL in XAMPP / MAMP /
WAMP
• Use IDE of choice (eclipse, notepad, notepad ++)
<?php
Print "Hello, World!";
?>
• Save to htdocs
6. PDO
• Class that represents a connection between PHP and a
database server
– (class is like a blueprint of how to construct something)
• Does not have to be mysql: Can be other databases
systems
• Used to use mysql extension which will be removed
soon <- lots of examples will use this!
• Good site explaining why nobody uses mysql extension
anymore: http://net.tutsplus.com/tutorials/php/php-
database-access-are-you-doing-it-correctly/
Phptherightway.com
12. Where is the transaction stored, in this
example?
13. Really boring transaction stuff Mark
left for me to do.
Transaction: a unit of work performed within a
database management system
14. Properties of reliable transactions..
• In relational databases transactions should
always have:
• Atomicity
• Consistency
• Isolation
• Durability
15. Atomicity
• Each transaction is all or nothing..
• It either does everything its supposed to do,
or nothing at all!
16. Consistency
• All data in the database is valid
• Any rules the database has must not be
broken!
17. Isolation
• Running transactions do not interfere with
each other
• Transactions that run at the same time is no
different from transactions ran one after
another