Layer 3 · Go deeper · 5 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Back of the envelope
Size it up
Tap through each step of the arithmetic.
Build-up · 6 steps
Two line items, one deadlock
Two requests on MySQL each add a line to the same order, then bump orders.total. Watch the locks on the order row.
Step 1 of 6
Two requests, one order
Each request adds a line to the same order, then updates orders.total. On MySQL, inserting a line runs a foreign key check on the order row.
4 interview moments
You’re the candidate
The interviewer pushes on the hard parts. Pick an approach and see how it holds up.
Deep dive 1 of 4
Interviewer
“Customers can close their accounts, and orders reference customers. Which ON DELETE action do you give orders.customer_id?”
Your move. Pick an approach:
Deep dive 2 of 4
Interviewer
“A merchant with 2M orders and 6M order lines leaves the platform. How do you remove their data?”
Your move. Pick an approach:
Deep dive 3 of 4
Interviewer
“Comments can attach to a restaurant, a dish or an order. How do you model the reference?”
Your move. Pick an approach:
Deep dive 4 of 4
Interviewer
“Your MySQL orders data is moving to Vitess shards, and every ALTER must go through gh-ost. Do foreign keys stay?”
Your move. Pick an approach: