-- rcnt.accounts definition -- Drop table -- DROP TABLE rcnt.accounts; CREATE TABLE rcnt.accounts ( acnt_id int4 NOT NULL GENERATED ALWAYS AS IDENTITY, acnt_dsply_name varchar(50) NOT NULL, acnt_description varchar(250) NULL, CONSTRAINT accounts_pkey PRIMARY KEY (acnt_id) ); -- rcnt.buckets definition -- Drop table -- DROP TABLE rcnt.buckets; CREATE TABLE rcnt.buckets ( bkt_id int4 NOT NULL GENERATED ALWAYS AS IDENTITY, bkt_dsply_code varchar(5) NOT NULL, bkt_dsply_name varchar(50) NULL, bkt_description varchar(250) NULL, CONSTRAINT buckets_pkey PRIMARY KEY (bkt_id) ); -- rcnt.transaction_breakdown definition -- Drop table --DROP TABLE rcnt.transaction_breakdown; CREATE TABLE rcnt.transaction_breakdown ( trns_brkdwn_id int4 NOT NULL GENERATED ALWAYS AS IDENTITY, trns_brkdwn_amount numeric(10, 3) NOT NULL, trns_brkdwn_parent_transaction int4 NOT NULL, trns_brkdwn_catagory int4 NULL, trns_brkdwn_bucket int4 NULL, CONSTRAINT transaction_breakdown_pkey PRIMARY KEY (trns_brkdwn_id) ); -- rcnt.transactions definition -- Drop table -- DROP TABLE rcnt.transactions; CREATE TABLE rcnt.transactions ( trns_id int4 NOT NULL GENERATED ALWAYS AS IDENTITY, trns_amount numeric(10, 3) NOT NULL, trns_description varchar(250) NULL, trns_account int4 NOT NULL, trns_bucket int4 NULL, trns_date Date not null, CONSTRAINT transactions_pkey PRIMARY KEY (trns_id) ); ALTER TABLE rcnt.transactions ADD CONSTRAINT transactions_trns_account_fkey FOREIGN KEY (trns_account) REFERENCES rcnt.accounts(acnt_id); ALTER TABLE rcnt.transactions ADD CONSTRAINT transactions_trns_bucket_fkey FOREIGN KEY (trns_bucket) REFERENCES rcnt.buckets(bkt_id) ON DELETE SET NULL; -- rcnt.transaction_categories definition -- Drop table -- DROP TABLE rcnt.transaction_categories; CREATE TABLE rcnt.transaction_categories ( trns_ctgry_id int4 NOT NULL GENERATED ALWAYS AS IDENTITY, trns_ctgry_dsply_code varchar(5) NOT NULL, trns_ctgry_dsply_name varchar(50) NOT NULL, trns_ctgry_description varchar(250) NULL, CONSTRAINT transaction_categories_pkey PRIMARY KEY (trns_ctgry_id) ); -- rcnt.transaction_breakdown foreign keys ALTER TABLE rcnt.transaction_breakdown ADD CONSTRAINT transaction_breakdown_trns_brkdwn_catagory_fkey FOREIGN KEY (trns_brkdwn_catagory) REFERENCES rcnt.transaction_categories(trns_ctgry_id) ON DELETE SET NULL; ALTER TABLE rcnt.transaction_breakdown ADD CONSTRAINT transaction_breakdown_trns_brkdwn_parent_transaction_fkey FOREIGN KEY (trns_brkdwn_parent_transaction) REFERENCES rcnt.transactions(trns_id) ON DELETE CASCADE; ALTER TABLE rcnt.transaction_breakdown ADD CONSTRAINT transaction_breakdown_trns_brkdwn_bucket_fkey FOREIGN KEY (trns_brkdwn_bucket) REFERENCES rcnt.buckets(bkt_id) ON DELETE SET NULL;