Given the following example:
CREATE TABLE bom (
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name varchar(255) NOT NULL
);
CREATE TABLE bom_item (
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
bom_id_fk INT REFERENCES bom(id) NOT NULL,
pcb_identifier varchar(50) NOT NULL
)
Is it possible to place an UNIQUE
constraint on bom_item.pcb_identifier
for a certain bom_id_fk
besides making them both PRIMARY KEY
?.
The logic behind that is, that a pcb_identifier
may only exist once in a certain BOM