テーブル作成の構文が知りたい
複合キーのあるテーブルの複合キーを
ほかのテーブルの外部キーとして使いたいが上手く書けません。
発生している問題・エラーメッセージ
ERROR: there is no unique constraint matching given keys for referenced table "reservable_room"
該当のソースコード
create table reservation( reservation_id serial primary key, start_time time not null, end_time time not null, reserved_date date not null,- room_id int references meeting_rooom(room_id), user_id varchar(255) references usr(user_id), FOREIGN KEY(reserved_date) references reservable_room(reserved_date)--ここがうまくいってない? ); //下三つのテーブルは作成済み create table reservable_room( reserved_date date, room_id int references meeting_rooom(room_id), primary key (reserved_date,room_id) ); create table usr( user_id varchar(255) primary key, first_name varchar(255) not null, last_name varchar(255) not null, pass varchar(255) not null, role_name varchar(255) not null ); create table meeting_rooom( room_id serial primary key, room_name varchar(255) not null );
試したこと
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/02 01:10
2018/09/02 05:25
2018/09/02 05:43