I've a users table:
id
type
merchant_id
agent_id
...
I want to add a check constraint using the following conditions:
if type == 'MERCHANT' then merchant_id is not null
if type == 'AGENT' then agent_id is not null
How this constraint is implemented?
Update:
I forgot to mention an extra requirement. the user can only have an agent_id or merchant_id.