Project 1: Fintech High-Performance Transaction Engine
Project 1: Fintech High-Performance Transaction Engine
Advanced Capstone Project 1: Fintech High-Performance Transaction Engine
Welcome to the first Advanced Capstone Project! In this enterprise-grade project, you will build a production-ready Fintech High-Performance Transaction Processing Engine.
You will synthesize:
- Multi-table double-entry bookkeeping
- Stored Procedures with
IN/OUTparameters - Deterministic locking order to prevent deadlocks
- Pessimistic locking (
SELECT ... FOR UPDATE) - Custom error handling (
DECLARE EXIT HANDLER FOR SQLEXCEPTION)
1. Database Schema DDL
2. Seeding Initial Accounts
3. The Core Settlement Stored Procedure
To eliminate deadlocks under high concurrency, our procedure uses Deterministic ID Sorting: it always locks the smaller account ID first, followed by the larger account ID!
4. Executing and Testing the Engine
Multiple Choice Questions
1. In our fintech procedure, why are account IDs sorted before acquiring locks with SELECT ... FOR UPDATE?
A. Because MySQL requires primary keys to be ordered alphabetically B. To enforce a deterministic locking order, completely eliminating circular deadlocks across concurrent transfer threads C. To reduce the amount of RAM used D. Because higher IDs have higher priority Answer: B Explanation: Consistently locking rows in ascending numerical order eliminates cyclical lock dependencies, preventing deadlocks.
2. How does the procedure guarantee that money cannot be transferred if the source has insufficient funds?
A. It alerts the server admin B. It checks IF v_src_bal < p_amount THEN ROLLBACK; and exits cleanly before making balance modifications C. It relies on MySQL credit limits D. It creates negative balances Answer: B Explanation: Pre-checking the locked balance and rolling back immediately guarantees that overdrafts are rejected before writing ledger records.
3. What does the DECLARE EXIT HANDLER FOR SQLEXCEPTION accomplish in our procedure?
A. Prints the SQL code to the screen B. Automatically issues a ROLLBACK and populates error output parameters if any unexpected database failure occurs C. Restarts the connection pool D. Deletes the transfer record Answer: B Explanation: The EXIT HANDLER catches unhandled database exceptions, guaranteeing that partial modifications are safely rolled back.
4. How many ledger records are posted in general_ledger for every successful transfer?
A. 1 B. Exactly 2 (One DEBIT and one CREDIT) C. 4 D. None Answer: B Explanation: Double-entry accounting requires two matching ledger records per transaction: a DEBIT to the sender and a CREDIT to the recipient.
5. Why is UUID() used for the transfer_uuid column?
A. It is shorter than an integer B. It provides a globally unique, non-sequential transaction reference identifier suitable for external API reconciliation C. It compresses the row D. It speeds up table scans Answer: B Explanation: A UUID serves as an immutable, globally unique idempotency key for external payments and audit tracking.
Project 2: Multi-Tenant Analytics Warehouse with Partitioning
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.