Q:

MySQL, possible to prevent two fields to be NULL or NOT NULL?

a simple table:
ID, NAME, POST_ID, GROUP_ID

either POST_ID or GROUP_ID must be set, but never both of them, NEITHER none of them. So,
there are valid cases:
ID, NAME, POST_ID, GROUP_ID
x,   y,   1,       NULL
x,   y,   NULL,    4

and NOT VALID cases:
ID, NAME, POST_ID, GROUP_ID
x,   y,   NULL,    NULL
x,   y,   4,       4

is it possible to set such complicated restriction rule?

A:

You have to use TRIGGERS on CREATE and UPDATE events and throw an exception when the condition (COALESCE(POST_ID, GROUP_ID) IS NULL OR (POST_ID IS NOT NULL AND GROUP_ID IS NOT NULL)) occurs
Here the answer to your question:
Either OR non-null constraints in MySQL
This is the procedure, slightly change the syntax depending on the version of MySql.

