Suppose I have the following tables
CREATE TABLE plugins (
id int primary key,
type text);
insert into plugins values (1,\'matrix\');
insert into plugins va
Use a compound key in the referenced table and a CHECK
constraint in the referencing table e.g.
CREATE TABLE plugins (
id int primary key,
type text,
UNIQUE (type, id)
);
CREATE TABLE matrix_params (
id int primary key,
plugintype text DEFAULT 'matrix' NOT NULL
CHECK (plugintype = 'matrix'),
pluginid int NOT NULL,
FOREIGN KEY (plugintype, pluginid)
references plugins (type, id)
);