Hola amigos intento ejecutar este sql y me da un error de restriccion , como se soluciona esto ??
drop table if exists contiene CASCADE;
CREATE TABLE contiene (
codpro character varying(5) NOT NULL,
num_caja character varying(5) NOT NULL,
cod_t character varying(5) NOT NULL,
cantidad numeric(10) NOT NULL,
precio_uni numeric(10) NOT NULL,
fecha_hora timestamp
);
drop table if exists recibo CASCADE;
CREATE TABLE recibo (
fecha_hora timestamp,
num_caja character varying(5) NOT NULL,
cod_t character varying(5) NOT NULL,
cod_emp character varying(5) NOT NULL
);
ALTER TABLE ONLY contiene
ADD CONSTRAINT cp_contiene PRIMARY KEY (num_caja, cod_t, codpro,fecha_hora);
ALTER TABLE ONLY recibo
ADD CONSTRAINT cp_recibo PRIMARY KEY (num_caja, cod_t, cod_emp);
AL ejecutar esto me sale el error
ALTER TABLE ONLY contiene
ADD CONSTRAINT cf_cod_t FOREIGN KEY (cod_t) REFERENCES recibo(cod_t) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY contiene
ADD CONSTRAINT cf_num_caja FOREIGN KEY (num_caja) REFERENCES recibo(num_caja) ON UPDATE CASCADE ON DELETE RESTRICT;
ALTER TABLE ONLY contiene
ADD CONSTRAINT cf_fecha_hora FOREIGN KEY (fecha_hora) REFERENCES recibo(fecha_hora) ON UPDATE CASCADE ON DELETE RESTRICT;