Hola Alvaro. >> CREATE TABLE bodegas /*la tabla es mucho más ancha*/ >> ( >> >> bodega character varying(3) NOT NULL, >> item character varying(15) NOT NULL, >> buffer numeric(12,3) DEFAULT 0, >> pedidos_clientes numeric(12,3) DEFAULT 0, >> comprometido_pedido numeric(10,3) DEFAULT 0, >> CONSTRAINT pk_bodegas PRIMARY KEY (bodega, item), >> CONSTRAINT fk_bodegas_id_bodegas FOREIGN KEY (bodega) >> REFERENCES id_bodegas (bodega) MATCH FULL >> ON UPDATE NO ACTION ON DELETE NO ACTION, >> CONSTRAINT fk_bodegas_item FOREIGN KEY (item) >> REFERENCES items (item) MATCH SIMPLE >> ON UPDATE NO ACTION ON DELETE NO ACTION
>> ) >¿tienes una llave foránea que dice que la bodega existe en la misma >tabla bodegas? ¿es decir, la tabla se autoreferencia? Suena medio >estúpido esto. ¿Qué sentido tiene? La tabla bodega tiene un FK a la tabla id_bodegas, no se autoreferencia. Saludos. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "People get annoyed when you try to debug them." (Larry Wall)