From: David Garamond <lists@zara.6.isreserved.com>
To: pgsql-sql@postgresql.org
Subject: order and order line item
Date: Wed, 28 Dec 2005 00:52:11 +0700
Message-ID: <43B17F4B.4010007@zara.6.isreserved.com> (raw)
Suppose we have the usual order & order line item entities:
CREATE TABLE "order" (
id INT PRIMARY KEY,
date DATE NOT NULL
);
CREATE TABLE orderlineitem (
id INT PRIMARY KEY,
orderid INT REFERENCES "order"(id),
seq INT NOT NULL,
CONSTRAINT con1 UNIQUE (orderid, seq),
productid INT NOT NULL,
quantity INT NOT NULL,
price NUMERIC(18,4) NOT NULL
);
how do we enforce things like, for example: a) each order must contain
at least 1 line item; or b) each order must have a non-zero total value;
without making INSERT painful? I'm new to triggers, so I'm thinking of
something like a "before COMMIT" trigger but there's no such thing
apparently.
Regards,
dave
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: lists@zara.6.isreserved.com
Subject: Re: order and order line item
In-Reply-To: <43B17F4B.4010007@zara.6.isreserved.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox