I have a problem creating a table that contains a foreign key from another table that has two primary keys.
Below are the tables:
create table names_types(
id_name serial,name varchar(70),type varchar(70),primary key(id_name,name)
);
create table risk_final(
id_risk serial,id_date varchar(70)references date_final(vdate_id)
,name varchar(70)references names_types(name)
,var_mc_risk varchar(70)
,mvar_mc_risk varchar(70)
,incvar_mc_risk varchar(70)
,cvar_mc_risk varchar(70)
,delta varchar(70)
,present_value varchar(70)
,net_exposure varchar(70)
,amount varchar(70)
,primary key(id_risk,id_date,name)
);
The table risk_final can't be created and gives me the ERROR:
ERROR: there is no unique constraint matching given keys for referenced table "names_types"
How can I solve it?