1

enter image description here

a constraint requires me that. "the value of B, present in table B1, must always be less than that of A present in table C1".

is it correct to implement two triggers to do this? one that is activated when B1 is inserted and modified and one when C1 is modified?

In the constraint dictionary documentation should it be indicated with a single constraint or separate ones?

2
  • Yep, those two triggers will enforce the rule you describe. Commented May 15 at 18:00
  • Or... you can add redundancy to table B1 and use a trivial constraint there. Commented May 15 at 18:01

1 Answer 1

0

The constraint spans two tables. So you cannot consider constraint checks as these are limited to a simple expression involving only columns of the same table.

Since each table could be updated independently, it is correct to consider a solution based on two BEFORE triggers, an UPDATE trigger on C1 and an UPDATE/INSERT trigger on B1 .

Regarding documentation, it is conceptually a single constraint in the model, which has to be enforced in two places in the implementation. I'd therefore recommend to document it as one constraint that is cross referenced several time in the implementation. This allows to keep the picture and remind that it is the two sides of the same coin, and not two different constraints. (unless you refer to some dictionary in a supporting tool, in which case you'd need to say more)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.