10 ¡things ¡every ¡dev. ¡should ¡ know ¡about ¡rela7onal ¡databases
…but ¡forgot ¡to ¡ask ¡
Piers ¡Williams ¡ @MrPiers ¡
10 things every dev. should know about rela7onal databases but - - PowerPoint PPT Presentation
10 things every dev. should know about rela7onal databases but forgot to ask Piers Williams @MrPiers Who He? So6ware Architect at Birchman (an SMS Company)
…but ¡forgot ¡to ¡ask ¡
Piers ¡Williams ¡ @MrPiers ¡
table ¡rela%ng ¡to ¡the ¡key. ¡
you’re ¡doing ¡it ¡wrong ¡
Title ¡ Author ¡ Borrower ¡ ContactEmail ¡ Public ¡Key ¡ Cryptosystems ¡ Alice ¡Key ¡ Robert ¡Plaintext ¡ bob@gmail.com ¡ Lonely ¡Planet ¡Russia ¡ Simon ¡Richmond ¡ Edward ¡Snowden ¡ guest@kremlin.ru ¡ Devilish ¡Hacks ¡ Louis ¡Cypher ¡ Edward ¡Snowden ¡ guest@kremlin.ru ¡ Title ¡ Author ¡ Borrower ¡ Public ¡Key ¡Crypto ¡Systems ¡ Alice ¡Key ¡ Robert ¡Plaintext ¡ Lonely ¡Planet ¡Russia ¡ Lonely ¡Planet ¡ Edward ¡Snowden ¡ Devilish ¡Hacks ¡ Louis ¡Cypher ¡ Edward ¡Snowden ¡ Borrower ¡ ContactEmail ¡ Robert ¡Plaintext ¡ bob@worried.com ¡ Edward ¡Snowden ¡ guest@kremlin.ru ¡
during ¡updates ¡
ID ¡ BookID ¡ Name ¡ Value ¡
1 ¡ 1 ¡ Title ¡ Public ¡Key ¡Cryptosystems ¡ 2 ¡ 1 ¡ Author ¡ Alice ¡Key ¡ 3 ¡ 1 ¡ ISBN ¡ 47381749023 ¡ 4 ¡ 1 ¡ ReleaseDate ¡ 20/01/2001 ¡ 5 ¡ 2 ¡ Title ¡ Lonely ¡Planet ¡Russia ¡ 6 ¡ 2 ¡ Author ¡ Simon ¡Richmond ¡ 7 ¡ 2 ¡ ISBN ¡ 6543215432 ¡ 8 ¡ 2 ¡ ReleaseDate ¡ 1/04/2010 ¡
Not ¡All ¡Queries ¡Are ¡Equal ¡(cont.) ¡
simultaneous ¡updates ¡on ¡a ¡row ¡
separately ¡
#Fail ¡ #Win ¡
“A ¡customer, ¡whose ¡ID ¡is ¡101, ¡contacted ¡his ¡local ¡shop ¡to ¡get ¡his ¡phone ¡recharged. ¡He ¡pays ¡ the ¡amount. ¡But ¡Fll ¡the ¡Fme ¡his ¡phone ¡was ¡about ¡to ¡recharge, ¡the ¡scheduled ¡Fme ¡of ¡the ¡ second ¡script ¡fired ¡the ¡second ¡script. ¡The ¡second ¡script ¡loaded ¡the ¡records ¡of ¡50,000 ¡ customers ¡in ¡the ¡memory. ¡In ¡this ¡in-‑memory ¡records, ¡one ¡of ¡the ¡record ¡of ¡this ¡customer ¡too. ¡ […] ¡ Now ¡what ¡happened ¡is ¡that ¡is ¡the ¡actual ¡table, ¡the ¡column: ¡"CurrentAccountBalance" ¡gets ¡ updated ¡to ¡150, ¡but ¡the ¡in-‑memory ¡records ¡on ¡which ¡the ¡second ¡script ¡was ¡working ¡had ¡ the ¡customer's ¡old ¡balance ¡i.e, ¡100” ¡ hrp://stackoverflow.com/quesFons/4071763/is-‑there-‑any-‑way-‑to-‑update-‑the-‑most-‑recent-‑ version-‑of-‑row-‑through-‑sql ¡ ¡ ¡
repeatable, ¡and ¡totals ¡can ¡change ¡
Best ¡Concurrency ¡ Best ¡Consistency ¡
Read ¡ Uncommired ¡
(maximum ¡crazy) ¡
Read ¡ Commired ¡
(unhinged) ¡
Repeatable ¡ Read ¡
(occasional ¡outbursts) ¡
Serializable ¡
(boringly ¡sane) ¡
weirdness ¡for ¡readers ¡
the ¡disk ¡once, ¡someFme ¡later ¡
condiFons ¡
languages ¡
columns ¡painful ¡
aggregates ¡(eg ¡averages) ¡
RDBMS ¡
requirements ¡
Something ¡else ¡