0
create table date_dimension (
id serial primary key,
date_id date,
..... others
);
create table temp (
id serial primary key,
from_date integer,
to_date integer,
value integer,
foreign key (from_date, to_date) references date_dimension(id, id)
);
我怎样才能既指from_date
和to_date
到id
场date_dimension
?
当前的代码无法做到这一点说Postgres的:两个外键,以相同的主键字段
ERROR: there is no unique constraint matching given keys for referenced table "date_dimension"
谢谢
我现在看到这个 - 错误:关系“date_dimension”的列“id”已经存在 – daydreamer
@daydreamer:这听起来像一个新问题,请到目前为止的所有代码问一个新问题。 – SingleNegationElimination
嗨@TokenMacGuy,这是因为我的愚蠢,你的解决方案是岩石!感谢:) – daydreamer