I have a code that is giving the following error:
there is no unique constraint matching given keys for referenced table "schedule"
Code:
CREATE TYPE weekday AS ENUM ('Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sabado');
-- Table Turma
CREATE TABLE TURMA
(
codigoTurma serial PRIMARY KEY,
nome character varying(50) NOT NULL UNIQUE
);
-- Table Horario
CREATE TABLE HORARIO
(
diaSemana weekday,
hora time,
PRIMARY KEY(diaSemana, hora)
);
-- Table: Horario Turma
create table HORARIOTURMA(
codigoTurma serial REFERENCES TURMA(codigoTurma),
diaSemana weekday REFERENCES HORARIO(diaSemana),
hora time REFERENCES HORARIO(hora),
PRIMARY KEY (codigoTurma, diaSemana, hora)
);
What might be causing this error?