Things I Wished More Developers Knew About Databases

An illustration of data loss if MongoDB crashes before it writes to the physical disk.
An overview of the existing concurrency models and the relationships between them.
An overview of concurrency anomalies at different isolation levels per database.
UPDATE products
SET name = 'Telegraph receiver', version = 2
WHERE id = 1 AND version = 1
BEGIN tx1;                      BEGIN tx2;SELECT COUNT(*) 
FROM operators
WHERE oncall = true;
0 SELECT COUNT(*)
FROM operators
WHERE oncall = TRUE;
0
UPDATE operators UPDATE operators
SET oncall = TRUE SET oncall = TRUE
WHERE userId = 4; WHERE userId = 2;
COMMIT tx1; COMMIT tx2;
result1 = T1() // results are actually promises
result2 = T2()
An example architecture where application servers are decoupled from the sharding service..
Application server reads 5-second old stale data from local replica even though the latest version is available on the other side of the Pacific Ocean.
Spanner components use TrueTime where TT.now() returns an interval, so Spanner can inject sleeps to ensure the current time has passed a particular timestamp.
with newTransaction():
Accounts.create("609-543-222")
with newTransaction():
Accounts.create("775-988-322")
throw Rollback();
function newAccount(id string) {
with newTransaction():
Accounts.create(id)
}
function newAccount(id string) {
Accounts.create(id)
}
// In main application:with newTransaction():
// Read some data from database for configuration.
// Generate an ID from the ID service.
Accounts.create(id)
Uploads.create(id) // create upload queue for the user.
var seq int64with newTransaction():
newSeq := atomic.Increment(&seq)
Entries.query(newSeq)
// Other operations...
SELECT * FROM articles where author = "rakyll" order by title;

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store