> Or you can use a view including the WITH CHECK OPTION. Deleting against the
view ensures that at least 20 records remain in the table.
How would you do that?
Or you stick with triggers.
A TRIGGER would definitely of service here.
....but...IMNHSO, i don't like the use of TRIGGERs for major things. If
the second TABLE was populated with DELETEs, but the second TABLE was
not used by the system, a TRIGGER makes a lot of sense as it is more
data management. But to have two TABLEs, and have a TRIGGER keep them
in sync for actual use (through a view), the application or stored
PROCEDURE should handle it. Otherwise it tends to get real messy.
IOW, the actual data model should not use TRIGGERs, only management
features like an non-natural Id COLUMN or a history TABLE (for "just in
case" purposes) or rights that cannot be otherwise implemented, or
auditing, etc should use TRIGGERs.
But that's just my opinion. :)
Based on the ugliness i've seen when people begin to rely on TRIGGERs
to populate other TABLEs, and then have to code around them.
B.