From 334cb0ff20caa63bdec9f2cae679c540698c0a1f Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Tue, 25 Nov 2008 01:10:54 +1300 Subject: [PATCH] Relational integrity constraints. --- dba/relational_integrity.sql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 dba/relational_integrity.sql diff --git a/dba/relational_integrity.sql b/dba/relational_integrity.sql new file mode 100644 index 0000000..2c2e3e4 --- /dev/null +++ b/dba/relational_integrity.sql @@ -0,0 +1,16 @@ +-- Apply relational integrity constraints to the database +-- + +-- First remove any existing ones... +ALTER TABLE invoiceline DROP CONSTRAINT "invoiceline_invoiceno_fkey"; +ALTER TABLE voucherline DROP CONSTRAINT "voucherline_voucherseq_fkey"; + + +-- Now add new ones. +ALTER TABLE invoiceline ADD CONSTRAINT "invoiceline_invoiceno_fkey" FOREIGN KEY (invoiceno) REFERENCES invoice(invoiceno) + ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE; + +ALTER TABLE voucherline ADD CONSTRAINT "voucherline_voucherseq_fkey" FOREIGN KEY (voucherseq) REFERENCES voucher(voucherseq) + ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE; + + -- 2.11.4.GIT