Assignment Overview
In this assignment, you will build a Banking System Database that handles money transfers, account operations, and audit logging - all with proper transaction safety and data integrity constraints.
Constraints
PK, FK, CHECK, UNIQUE, NOT NULL
Transactions
BEGIN, COMMIT, ROLLBACK, SAVEPOINT
Concurrency
Isolation levels, locking
The Scenario
SecureBank Database
You're building the core database for SecureBank. The bank requires bulletproof transaction handling where money transfers either complete fully or not at all.
"If a transfer fails halfway through, we cannot have money disappear. Every transaction must be atomic, consistent, isolated, and durable."
Implementation Tasks
Schema with Constraints (5 tasks)
- Accounts table with balance CHECK (>= 0)
- Transactions table with FK to accounts
- UNIQUE constraint on account numbers
- NOT NULL constraints on critical fields
- Audit log table for tracking changes
Transaction Scripts (5 tasks)
- Money transfer between accounts (atomic)
- Transaction with savepoint for partial rollback
- Multi-step operation with error handling
- Demonstrate COMMIT success scenario
- Demonstrate ROLLBACK failure scenario
Integrity Verification (5 tasks)
- Test constraint violation handling
- Verify referential integrity on delete
- Demonstrate isolation level behavior
- Create audit trigger for balance changes
- Write verification queries for data consistency
Submission Guidelines
GitHub Repository
- Create a repository named
sql-assignment-7-transactions - Include
schema.sqlwith constrained tables - Include
transactions.sqlwith transaction scripts - Include
test-cases.sqlwith verification tests - Document each ACID property demonstration
Grading Rubric
| Criteria | Points |
|---|---|
| Schema with constraints (5 × 10 pts) | 50 |
| Transaction scripts (5 × 10 pts) | 50 |
| Integrity verification (5 × 10 pts) | 50 |
| Total | 150 |