1473 shaares
101 private links
101 private links
Code for Postgres:
ALTER TABLE users ADD CONSTRAINT enforce_single_not_null_column CHECK(
(CAST(parent_id IS NOT NULL AS int) +
CAST(teacher_id IS NOT NULL AS int)) <= 1)
ALTER TABLE users ADD CONSTRAINT enforce_single_not_null_column CHECK(
(CAST(parent_id IS NOT NULL AS int) +
CAST(teacher_id IS NOT NULL AS int)) <= 1)