Library › Book 15 › Stored Procedures and Triggers -- Testing Hidden Logic
Stored Procedures and Triggers -- Testing Hidden Logic
10.1🔒Why Business Logic Lives in the DatabaseBusiness logic that lives in the database -- stored procedures, functions, and triggers -- must be tested like any other code. These are…
10.2🔒Testing Stored Procedures
10.3🔒Testing Edge CasesPro Tip: Financial calculations are the number one source of precision bugs. Always use DECIMAL/NUMERIC types for money, never FLOAT or…
10.4🔒Testing TriggersTriggers run automatically when data is inserted, updated, or deleted. They are invisible to the application -- which makes them especially…
10.5🔒Testing Computed and Derived Values
10.6🔒Testing Procedure Error Handling
10.7🔒Practice Schema 9: Audit and Compliance
10.8🔒ExercisesBeginner:
10.9🔒Q&AResume phrasing- Built test suites for 15+ stored procedures and database triggers, covering edge cases (empty inputs, overflow, precision errors) that…
10.10🔒Q&ACover letter framingDatabase logic -- stored procedures, triggers, computed columns -- is some of the hardest code to test because it is invisible to the…
10.11🔒Q&AInterview framing"I approach database logic testing the same way I approach application code testing: positive cases, negative cases, edge cases, and error…
10.12🔒Q&AWhat not to say- "I trust stored procedures because the DBA wrote them." -- All code needs testing, regardless of who wrote it. - "I only test the happy…
10.13🔒Q&AQuestion 1Prompt: Your application uses a trigger that automatically updates the updated_at timestamp whenever a row in the users table is modified…
10.14🔒Q&AQuestion 2Prompt: You are testing a transfer_funds stored procedure that debits one account and credits another. The procedure should reject…
10.15🔒Q&AQuestion 3Prompt: Your team has implemented an audit trail trigger that logs all changes to the users table into an audit_log table. After a…
10.16🔒Q&AQuestion 4Prompt: A financial system uses a stored procedure that calculates order totals. During testing, you find that 3 * 0.10 returns…