I'd like to ensure that the creation of a department also implies the creation of two to eight projects; no more, no less:

CREATE TABLE departments (
 department text primary key not null
);

CREATE TABLE projects (
project text primary key not null,
department text not null
 references departments(department)
 on delete cascade
 on update cascade
);

So it'd be nice to have an INSERT trigger that's fired on departments at the end of the transaction to ensure that between two and eight projects exist for the newly created department.

Is there no way to achieve the above stated goal in the server? Must I rely on the application to enforce consistency?

Mike Mascari



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
     subscribe-nomail command to [EMAIL PROTECTED] so that your
     message can get through to the mailing list cleanly

Reply via email to