I am building a database that has system barcodes, as well as the option for custom barcodes. I have a unique constraint on custom_barcode and system_barcode.
What I would like to do is have it so if custom_barcode has a value of “123”, no other row can have custom_barcode OR system_barcode with a value of “123". I am not trying to make a 2-column unique constraint where if custom_barcode is "123" and system_barcode is "456", that combination cannot exist again. Is it possible to achieve this? I'm wondering if this needs to be achieved with a trigger.