That is close, but will stop one from deleting two parts with the same label. You're proposal in the description is actually closer, but can't be done with a CONSTRAINT directly. Instead, we need a partial unique index. Something like:
ALTER TABLE biblio.monograph_part DROP CONSTRAINT "record_label_unique";
CREATE INDEX CONCURRENTLY record_label_unique_idx ON biblio.monograph_part (record, label) WHERE deleted = FALSE;
Steve,
That is close, but will stop one from deleting two parts with the same label. You're proposal in the description is actually closer, but can't be done with a CONSTRAINT directly. Instead, we need a partial unique index. Something like:
ALTER TABLE biblio. monograph_ part DROP CONSTRAINT "record_ label_unique" ; label_unique_ idx ON biblio. monograph_ part (record, label) WHERE deleted = FALSE;
CREATE INDEX CONCURRENTLY record_