SA
Sanaurrehmanarain/Bank-Vault-Core-SQL
A secure, ACID-compliant banking database system featuring stored procedures for safe money transfers and automated triggers for fraud detection.
๐ฆ Bank Vault Core: ACID Compliant Banking DB
๐ Overview
This project simulates a secure banking backend. Unlike standard analytics databases, this system focuses on Data Integrity and Transactional Safety.
It features:
- Stored Procedures to handle money transfers safely.
- Triggers to automatically flag suspicious high-value transactions.
- Normalized Schema for customers, accounts, and loans.
๐ The "Huge Plus": What is ACID?
In banking, you cannot afford to lose money due to a server crash. This project implements ACID properties using MySQL Transactions.
A - Atomicity (All or Nothing)
- Concept: A transaction involves multiple steps (deduct money, add money, log it). If step 3 fails, steps 1 and 2 must be undone.
- Implementation: Inside
transfer_funds, I useSTART TRANSACTION,COMMIT, andROLLBACK. If funds are insufficient, the entire process is rolled back.
C - Consistency (Rules are Followed)
- Concept: The database must remain in a valid state before and after the transaction.
- Implementation: Foreign Keys ensuring transactions are linked to real accounts; checks ensuring balances don't drop below allowed limits.
I - Isolation (Don't Interfere)
- Concept: Two transfers happening at the exact same millisecond shouldn't corrupt the balance.
- Implementation: MySQL handles row-level locking during the
UPDATEstatements in the stored procedure.
D - Durability (Saved Forever)
- Concept: Once
COMMITis executed, the data is saved to the disk even if the power goes out immediately after.
๐ ๏ธ Key Features Code
1. The Secure Transfer (Stored Procedure)
START TRANSACTION;
UPDATE accounts SET balance = balance - 500 WHERE id = 1;
UPDATE accounts SET balance = balance + 500 WHERE id = 2;
-- If any error happens here -> ROLLBACK
COMMIT;2. Fraud Detection (Trigger)
Automated monitoring system that watches every INSERT into the transactions table.
IF NEW.amount > 10000 THEN
INSERT INTO fraud_alerts ...
END IF;๐ How to Run
-
Create database
banking_system. -
Run
schema.sqlto build tables. -
Run
logic.sqlto load procedures and triggers. -
Run
analysis.sqlto simulate transfers and view reports.
On this page
Contributors
MIT License
Created January 31, 2026
Updated January 31, 2026
