C
C
cicatrix2018-05-10 12:43:35
SQL
cicatrix, 2018-05-10 12:43:35

How to make a selective check for not null in a table (check constraint)?

Hello colleagues.
The question is so simple: there is a table with fields FIELD_A, FIELD_B and FIELD_C. It is
necessary to set the following restrictions:
A and B must be filled (NOT NULL), and then C must be NULL
or C must be filled, but then both A and B must be NULL
That is, either there is C and there should not be either A or B, or both A and B are (required together), but then there should not be C.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin Tsvetkov, 2018-05-10
@tsklab

Need to set limits
Dependence of values ​​in a kartage is a violation of the normal form.

V
vanyamba-electronics, 2018-05-10
@vanyamba-electronics

I would do so.
In the first table, select a related table. Either table 2 or table 3.
In table 2, values ​​A and B, in table 3, values ​​C.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question