
/* AB3901T00 - TECNICOS_ENTIDAD */

ALTER TABLE AB39A.AB3901T00 ADD CONSTRAINT FK_AB3901T00_AB3916T00 FOREIGN KEY (TIPOIDENTIF) REFERENCES AB39A.AB3916T00 (CODIGO);


/* AB3902T00 - ENTIDADES */

ALTER TABLE AB39A.AB3902T00 ADD CONSTRAINT FK_AB3902T00_AB3916T00 FOREIGN KEY (TIPOIDENTIF) REFERENCES AB39A.AB3916T00 (CODIGO);
ALTER TABLE AB39A.AB3902T00 ADD CONSTRAINT FK_AB3902T00_AB3903T00 FOREIGN KEY (TIPO_ENTIDAD) REFERENCES AB39A.AB3903T00 (ID_TIPOORGANIZACION);


/* AB3906T00 - ACCIONES */

ALTER TABLE AB39A.AB3906T00 ADD CONSTRAINT FK_AB3906T00_AB3905T00 FOREIGN KEY (IDELEMENTO) REFERENCES AB39A.AB3905T00 (ID_ELEMENTO);

/* AB3907T00 - PLANES_ESTRATEGICOS */

ALTER TABLE AB39A.AB3907T00 ADD CONSTRAINT FK_AB3907T00_AB3902T00 FOREIGN KEY (CODENTIDAD) REFERENCES AB39A.AB3902T00 (CODENTIDAD);
ALTER TABLE AB39A.AB3907T00 ADD CONSTRAINT FK_AB3907T00_AB3913T00 FOREIGN KEY (CODPLANIFICACION) REFERENCES AB39A.AB3913T00 (CODPLANIFICACION);
ALTER TABLE AB39A.AB3907T00 ADD CONSTRAINT FK_AB3907T00_AB3901T00 FOREIGN KEY (CODTECNICOBAJA) REFERENCES AB39A.AB3901T00 (CODTECNICO);



/* AB3908T00 - ELEMENTOS_PE */

-- ALTER TABLE AB39A.AB3908T00 ADD CONSTRAINT FK_AB3908T00_AB3905T00 FOREIGN KEY (IDELEMENTO) REFERENCES AB39A.AB3905T00 (ID_ELEMENTO);
ALTER TABLE AB39A.AB3908T00 ADD CONSTRAINT FK_AB3908T00_AB3907T00 FOREIGN KEY (CODPLANE, CODVERSIONPE) REFERENCES AB39A.AB3907T00 (CODPLANE,CODVERSION);
ALTER TABLE AB39A.AB3908T00 ADD CONSTRAINT FK_AB3908T00_AB3908T00 FOREIGN KEY (CODELEMENTOPEPADRE) REFERENCES AB39A.AB3908T00 (CODELEMENTOPE);

/* AB3909T00 - PLANES_GESTION */

-- no deja si no es pk entera
-- ALTER TABLE AB39A.AB3909T00 ADD CONSTRAINT FK_AB3909T00_AB3907T00 FOREIGN KEY (CODPLANE) REFERENCES AB39A.AB3907T00 (CODPLANE);

ALTER TABLE AB39A.AB3909T00 ADD CONSTRAINT FK_AB3909T00_AB3901T00 FOREIGN KEY (CODTECNICOBAJA) REFERENCES AB39A.AB3901T00 (CODTECNICO);


/* AB3910T00 - ELEMENTOS_PG */

ALTER TABLE AB39A.AB3910T00 ADD CONSTRAINT FK_AB3910T00_AB3908T00 FOREIGN KEY (CODELEMENTOPE) REFERENCES AB39A.AB3908T00 (CODELEMENTOPE);
ALTER TABLE AB39A.AB3910T00 ADD CONSTRAINT FK_AB3910T00_AB3909T00 FOREIGN KEY (CODPLANG) REFERENCES AB39A.AB3909T00 (CODPLANG);
ALTER TABLE AB39A.AB3910T00 ADD CONSTRAINT FK_AB3910T00_AB3910T00 FOREIGN KEY (CODELEMPGPADRE) REFERENCES AB39A.AB3910T00 (CODELEMPG);

/* AB3911T00 - ACCIONES_PG */

ALTER TABLE AB39A.AB3911T00 ADD CONSTRAINT FK_AB3911T00_AB3906T00 FOREIGN KEY (IDACCION) REFERENCES AB39A.AB3906T00 (IDACCION);
ALTER TABLE AB39A.AB3911T00 ADD CONSTRAINT FK_AB3911T00_AB3910T00 FOREIGN KEY (CODELEMPG) REFERENCES AB39A.AB3910T00 (CODELEMPG);
ALTER TABLE AB39A.AB3911T00 ADD CONSTRAINT FK_AB3911T00_AB3912T00 FOREIGN KEY (CODTIPORECEPTOR) REFERENCES AB39A.AB3912T00 (CODTIPORECEP);

/* AB13T00 - PLANIFICACION */

-- ALTER TABLE AB39A.AB3913T00 ADD CONSTRAINT FK_AB3913T00_AB3903T00 FOREIGN KEY (TIPO_ENTIDAD) REFERENCES AB39A.AB3903T00 (ID_TIPOORGANIZACION);


/* AB14T00 - EJE_PE */

ALTER TABLE AB39A.AB3914T00 ADD CONSTRAINT FK_AB3914T00_AB3904T00 FOREIGN KEY (ID_EJE) REFERENCES AB39A.AB3904T00 (ID_EJE);

-- no deja si no es pk entera
-- ALTER TABLE AB39A.AB3914T00 ADD CONSTRAINT FK_AB3914T00_AB3907T00 FOREIGN KEY (CODPLANE) REFERENCES AB39A.AB3907T00 (CODPLANE);

/* AB3915T00 - ENTIDAD_TECNICO */

ALTER TABLE AB39A.AB3915T00 ADD CONSTRAINT FK_AB3915T00_AB3901T00 FOREIGN KEY (CODTECNICO) REFERENCES AB39A.AB3901T00 (CODTECNICO);
ALTER TABLE AB39A.AB3915T00 ADD CONSTRAINT FK_AB3915T00_AB3902T00 FOREIGN KEY (CODENTIDAD) REFERENCES AB39A.AB3902T00 (CODENTIDAD);


/* AB3917T00 - PLANESESTR_TECNICOS */

ALTER TABLE AB39A.AB3917T00 ADD CONSTRAINT FK_AB3917T00_AB3901T00 FOREIGN KEY (CODTECNICO) REFERENCES AB39A.AB3901T00 (CODTECNICO);
-- no deja si la pk no es entera
-- ALTER TABLE AB39A.AB3917T00 ADD CONSTRAINT FK_AB3917T00_AB3907T00 FOREIGN KEY (CODPLANE) REFERENCES AB39A.AB3907T00 (CODPLANE);

COMMIT;
EXIT;
