我正在为 PostgreSQL 使用 pgAdmin III,但我在 3 个表之间遇到外键问题。我的表是:
Locale with a primary key IDnegozio (integer type, no need to make it serial type) Orario with a primary key IDorario (integer type, no need to make it serial type) OrarioToLocale两列:IDlocaleT & IDorarioT(均为整数)。
我正在尝试在 IDlocale -> IDlocaleT 和 IDorario -> IDorarioT 之间创建一个外键,这样我就可以得到一个 Shop 可以有多个时间的关系。问题是,当我尝试制作这些外键时,出现了一个错误:“没有为引用表提供唯一约束匹配键”,我不明白为什么。我试图用谷歌搜索,但没有找到任何答案!我能怎么做?
这是三个表的代码:
CREATE TABLE public."Locale"
(
"IDnegozio" integer NOT NULL DEFAULT nextval('"Locale_IDnegozio_seq"'::regclass),
CONSTRAINT "Locale_pkey" PRIMARY KEY ("IDnegozio"),
)
CREATE TABLE public."Orario"
(
"IDorario" integer NOT NULL DEFAULT nextval('"Orario_IDorario_seq"'::regclass),
CONSTRAINT "Orario_pkey" PRIMARY KEY ("IDorario")
)
CREATE TABLE public."OrarioToLocale"
(
"IDlocaleT" integer NOT NULL,
"IDorarioT" integer NOT NULL
)
我能怎么做?谢谢指教!