Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/05/2011, 08:41
alejitagomez1987
 
Fecha de Ingreso: mayo-2011
Mensajes: 11
Antigüedad: 13 años
Puntos: 0
Error al insertar datos en una tabla con llave foranea

Hola, tengo mi base de datos en PostgreSQL, con estas tablas

CREATE TABLE persona
(
cedula integer NOT NULL,
nombre character(100),
apellido character(100),
telefono character(100),
direccion character(100),
correo character(100),
cargo character(100),
CONSTRAINT persona_pkey PRIMARY KEY (cedula)
)
WITH (
OIDS=FALSE
);
ALTER TABLE persona OWNER TO postgres;


CREATE TABLE municipios
(
id_municipios integer NOT NULL,
nombre_municipio character(20),
CONSTRAINT municipios_pkey PRIMARY KEY (id_municipios)
)
WITH (
OIDS=FALSE
);
ALTER TABLE municipios OWNER TO postgres;


CREATE TABLE deportivo
(
id_deportivo integer NOT NULL,
persona_cedula integer NOT NULL,
municipios_id_municipios integer NOT NULL,
resolucion_deportivo character(100),
nombre_deportivo character(100),
CONSTRAINT deportivo_pkey PRIMARY KEY (id_deportivo),
CONSTRAINT deportivo_id_deportivo_fkey FOREIGN KEY (id_deportivo)
REFERENCES municipios (id_municipios) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT deportivo_id_deportivo_fkey1 FOREIGN KEY (id_deportivo)
REFERENCES persona (cedula) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE deportivo OWNER TO postgres;


Ya inserte los datos en municipio y en persona pero al insertar los datos en deportivo me sale un error:

INSERT INTO deportivo(persona_cedula,municipios_id_municipios, id_deportivo, resolucion_deportivo, nombre_Deportivo)
VALUES ('10246811','10','1 ',' res 123 ',' LIGA 1' );
INSERT INTO deportivo(persona_cedula,municipios_id_municipios, id_deportivo, resolucion_deportivo, nombre_Deportivo)
VALUES ('29613849','8','2 ',' res 124 ',' LIGA 2' );

y me muestra este error:

ERROR: inserción o actualización en la tabla «deportivo» viola la llave foránea «deportivo_id_deportivo_fkey1»
DETAIL: La llave (id_deportivo)=(1) no está presente en la tabla «persona».

********** Error **********

ERROR: inserción o actualización en la tabla «deportivo» viola la llave foránea «deportivo_id_deportivo_fkey1»
Estado SQL:23503
Detalle:La llave (id_deportivo)=(1) no está presente en la tabla «persona».

Me pueden ayudar?????