我有一个date_dimension表定义:
date_dimension
CREATE TABLE date_dimension ( id integer primary key, date text, year double precision, year_for_week double precision, quarter double precision );
我正在尝试创建fact失败的表
fact
create table fact ( id serial primary key, contract integer, component integer, evaluation_date integer, effective_date integer, foreign key (evaluation_date, effective_date) references date_dimension(id, id) );
错误是:
ERROR: there is no unique constraint matching given keys for referenced table "date_dimension" SQL state: 42830
我不确定如何解决此问题。
我认为您正在寻找两个单独的外键:
foreign key (evaluation_date) references date_dimension(id), foreign key (effective_date) references date_dimension(id)