DROP TABLE AD74A66T00 CASCADE CONSTRAINTS PURGE;
DROP SEQUENCE AD74A66T00_SEQ;
DROP SYNONYM HIST_ESTUDIO_ALTA;
DROP SYNONYM SEQ_HIST_ESTUIDO_ALTA;

DROP TABLE AD74A67T00 CASCADE CONSTRAINTS PURGE;
DROP SEQUENCE AD74A67T00_SEQ;
DROP SYNONYM SEGUIMIENTO_USUARIOS;
DROP SYNONYM SEQ_SEGUIMIENTO_USUARIOS;


-----------------------------------------
/* AD74A66T00 - HIST_ESTUDIO_ALTA */
-----------------------------------------
CREATE TABLE AD74A66T00 (	
	ID_HISTORICO_66 NUMBER NOT NULL,
	USUARIO_66 VARCHAR2(10 BYTE) NOT NULL,
	FECHA_HISTORICO_66 DATE NOT NULL,
	ID_EXPEDIENTE_66 NUMBER NOT NULL
) TABLESPACE AD7401E00;

ALTER TABLE AD74A66T00 ADD CONSTRAINT AD74A66T00_PK 
	PRIMARY KEY (ID_HISTORICO_66) USING INDEX TABLESPACE  AD7402E00;
  
   COMMENT ON COLUMN AD74A66T00.ID_HISTORICO_66 IS 'Idetificador interno del seguimiento';
   COMMENT ON COLUMN AD74A66T00.USUARIO_66 IS 'Usuario';
   COMMENT ON COLUMN AD74A66T00.FECHA_HISTORICO_66 IS 'Fecha del histórico';
   COMMENT ON COLUMN AD74A66T00.ID_EXPEDIENTE_66 IS 'Expediente de alta relacionado';
   
   COMMENT ON TABLE  AD74A66T00  IS 'Tabla con el histórico de estudios de alta finalizados';  

ALTER TABLE AD74A66T00
ADD CONSTRAINT AD74A66T00_FK00 FOREIGN KEY ( ID_EXPEDIENTE_66)
REFERENCES AD74A00T00 ( ID_EXPEDIENTE_00 ) ENABLE;

CREATE OR REPLACE EDITIONABLE SYNONYM HIST_ESTUDIO_ALTA FOR AD74A.AD74A66T00;

CREATE SEQUENCE AD74A66T00_SEQ  MINVALUE 1 MAXVALUE 99999999 INCREMENT BY 1 START WITH 1 NOCACHE  NOORDER  NOCYCLE;
CREATE OR REPLACE EDITIONABLE SYNONYM SEQ_HIST_ESTUIDO_ALTA FOR AD74A.AD74A66T00_SEQ;

-----------------------------------------
/* AD74A67T00 - SEGUIMIENTO_USUARIOS */
-----------------------------------------
CREATE TABLE AD74A67T00 (	
	ID_SEGUIMIENTO_67 NUMBER NOT NULL,
	USUARIO_67 VARCHAR2(10 BYTE) NOT NULL,
	FECHA_SEGUIMIENTO_67 DATE NOT NULL,
	TOTAL_67 NUMBER(3,0) NOT NULL
) TABLESPACE AD7401E00;

ALTER TABLE AD74A67T00 ADD CONSTRAINT AD74A67T00_PK 
	PRIMARY KEY (ID_SEGUIMIENTO_67) USING INDEX TABLESPACE  AD7402E00;
  
   COMMENT ON COLUMN AD74A67T00.ID_SEGUIMIENTO_67 IS 'Idetificador interno del seguimiento';
   COMMENT ON COLUMN AD74A67T00.USUARIO_67 IS 'Usuario';
   COMMENT ON COLUMN AD74A67T00.FECHA_SEGUIMIENTO_67 IS 'Fecha del seguimiento';
   COMMENT ON COLUMN AD74A67T00.TOTAL_67 IS 'Total de expedientes del usuario/día';
   
   COMMENT ON TABLE  AD74A67T00  IS 'Tabla con el seguimento de expedientes por usuario';  

CREATE OR REPLACE EDITIONABLE SYNONYM SEGUIMIENTO_USUARIOS FOR AD74A.AD74A67T00;

CREATE SEQUENCE AD74A67T00_SEQ  MINVALUE 1 MAXVALUE 99999999 INCREMENT BY 1 START WITH 1 NOCACHE  NOORDER  NOCYCLE;
CREATE OR REPLACE EDITIONABLE SYNONYM SEQ_SEGUIMIENTO_USUARIOS FOR AD74A.AD74A67T00_SEQ;

COMMIT;

/