Bank Database

File/Directory Description
build.sql Script that invokes other scripts to create tables and populate them, using triggers to get branch assets values correct.
schema.sql SQL DDL definitions for Bank database.
rmdb.sql Cleans up all tables from existing Bank database. Won't work if there are functions and views that refer to these tables.
populate.sql Statements to add tuples to all tables. Should only be run after assets triggers are installed.
branches.sql Function to print a report on customers and assets for each branch. An example of using PLpgSQL to create complex (non-tabular) output. (Exercise)
totsal.sql Three small functions that show various ways to extract a total from a query (including implicit and explicit cursors).
layoff.sql Functions to implement downsizing (Exercise).
assets.sql Triggers to ensure that branch assets match the balances held in accounts at each branch.
withdraw.sql Three versions of a function to withdraw money from an account. In order of increasing complexity in how much error checking they do.