/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 15/9/2023 9:21:07 */
/*==============================================================*/
drop table if exists ACREDITACION;
drop table if exists CADAVER;
drop table if exists CADENA_CUSTODIA;
drop table if exists CATALOGO;
drop table if exists CATALOGO_CADAVER;
drop table if exists CONFIGURACION_INFORME;
drop table if exists DETALLE_INFORME;
drop table if exists FORMULARIO_CHECK_LIST_IOT;
drop table if exists GEO_SEMPLADES;
drop table if exists GRADO_CARGO;
drop table if exists HOJA_DE_RESPONSABILIDAD;
drop table if exists INDICIOS_CONSTATACIONES;
drop table if exists INFORME_PERICIAL;
drop table if exists INSTITUCION_UNIDAD;
drop table if exists MODULOS;
drop table if exists PERMISOS;
drop table if exists PERSONA;
drop table if exists PERSONA_CARGO;
drop table if exists RESPONSABLES;
drop table if exists TIPO_FOTOGRAFIA;
drop table if exists TIPO_INFORME;
drop table if exists USUARIO;
/*==============================================================*/
/* Table: ACREDITACION */
/*==============================================================*/
create table acreditacion
(
id_acreditacion int not null auto_increment comment 'identificador de la
tabla',
descripcion varchar(200) not null comment 'nombre de la acreditación',
fecha_acreditacion date not null comment 'fecha inicio de la acreditación',
fecha_fin date not null comment 'fecha fin de la acreditación',
primary key (id_acreditacion)
);
alter table acreditacion comment 'acreditacion de perito';
/*==============================================================*/
/* table: cadaver */
/*==============================================================*/
create table cadaver
(
id_pos_cadaver int not null auto_increment comment 'identificador de la
tabla',
id_checklist int comment 'identificador de la tabla',
id_cat_cadaver int,
id_persona int comment 'identificador de la tabla',
identificador char(4) not null comment 'letra que representa al cadaver
(a, b, c)',
ubicacion varchar(300),
otra_caracteristica varchar(200),
doc_identificacion char(1) comment 's: si
n: no',
familiares char(1) comment 's: si
n: no',
necrodactilias char(1) comment 's: si
n: no',
nota_adicional varchar(200),
primary key (id_pos_cadaver)
);
alter table cadaver comment 'es la posición en la cual se encuentra el cadaver al
momento';
/*==============================================================*/
/* table: cadena_custodia */
/*==============================================================*/
create table cadena_custodia
(
id_custodia int not null auto_increment,
id_catalogo int comment 'identificador de la tabla catalogo',
id_checklist int comment 'identificador de la tabla',
id_responsable int comment 'identificacion de la tabla responsable',
descripcion varchar(100) not null comment 'descripción de indicios a
enviar',
observacon varchar(200) comment 'se describe quien, donde se va a
enviar el indicios',
num_cadena_custodia varchar(200),
primary key (id_custodia)
);
alter table cadena_custodia comment 'traslado de indicios a las distintas unidades
según correspo';
/*==============================================================*/
/* table: catalogo */
/*==============================================================*/
create table catalogo
(
id_catalogo int not null auto_increment comment 'identificador de la
tabla catalogo',
cat_id_catalogo int comment 'identificador de la tabla catalogo',
descripcion varchar(150) not null comment 'descripcion de las opciones
de las operaciones a realizarse',
primary key (id_catalogo)
);
alter table catalogo comment 'catalogo de las operaciones a realizarse';
/*==============================================================*/
/* table: catalogo_cadaver */
/*==============================================================*/
create table catalogo_cadaver
(
id_cat_cadaver int not null auto_increment,
cat_id_cat_cadaver int,
descripcion varchar(200) not null,
primary key (id_cat_cadaver)
);
alter table catalogo_cadaver comment 'catalogo de posicion, orientación y
descripción
fenome';
/*==============================================================*/
/* table: configuracion_informe */
/*==============================================================*/
create table configuracion_informe
(
id_conf_inf int not null auto_increment,
titulo varchar(100) not null,
detalle longtext not null,
orden int not null,
primary key (id_conf_inf)
);
/*==============================================================*/
/* table: detalle_informe */
/*==============================================================*/
create table detalle_informe
(
id_detalle_inf int not null auto_increment comment 'identificador de la
tabla',
id_catalogo int comment 'identificador de la tabla catalogo',
id_checklist int comment 'identificador de la tabla',
descripcion varchar(200) comment 'descripcion de variable si no se
encuentra en el catalogo',
detalle varchar(200) comment 'detalle técnico de la opcion
seleccionada (técnicas para el revelado de rastros dactilares)',
primary key (id_detalle_inf)
);
alter table detalle_informe comment 'detalles de
proteccion y observación del lugar de los ';
/*==============================================================*/
/* table: formulario_check_list_iot */
/*==============================================================*/
create table formulario_check_list_iot
(
id_checklist int not null auto_increment comment 'identificador de la
tabla',
id_hresponsabilidad int comment 'id primario de la tabla',
id_geo int comment 'identificador de la tabla',
fecha date not null comment 'fecha del lugar de los hechos',
hora_notificacion time not null comment 'hora de la notificacion',
hora_llegada time not null comment 'hora de llegada',
hora_finalizacion time comment 'hora de finalizacion',
evento numeric(15,0) comment 'número de evento del ecu911',
latitud varchar(15) not null comment 'latitud de la ubicacion del
lugar de los hechos',
longitud varchar(15) not null comment 'longitud de la ubicacion del
lugar de los hechos',
num_domicilio numeric(3,0) comment 'número del domicilio',
calle_principal char(100) not null comment 'callle principal del lugar de
los hechos',
calle_secundaria varchar(100) comment 'calle secundaria del lugar de los
hechos',
lug_protegida varchar(1) not null default 'n' comment 'lugar del hecho
protegida (s: si, n: no)',
lug_manipulado varchar(1) not null default 'n' comment 'lugar del hecho
manipulado (s: si, n; no)',
quien_manipula varchar(100) comment 'persona que manipulo el lugar de los
hechos (personal policial, familiares, otros)',
desc_manipulacion varchar(200) comment 'descripción de la manipulación',
accion_tomada varchar(100) comment 'accion tomada por iot (acordono,
redefinio, cerco, etc)',
requiriente varchar(30) comment 'quien requirio que acuda la ucm',
des_alteracion varchar(200) comment 'descripcion de la alteración',
tipo_proteccion varchar(200),
alumbrado_publico char(1) comment 's: si
n: no',
senalizacion char(1),
veredas_bordillos char(1),
des_lugar varchar(100),
primary key (id_checklist)
);
alter table formulario_check_list_iot comment 'registro de los datos generales del
check list';
/*==============================================================*/
/* table: geo_semplades */
/*==============================================================*/
create table geo_semplades
(
id_geo int not null auto_increment comment 'identificador de la
tabla',
geo_id_geo int comment 'identificador de la tabla',
codigo varchar(15) not null comment 'codigo de ubicacion',
descripcion varchar(100) not null comment 'descripcion (zona, subzona,
distrito, circuito, subcircuito)',
primary key (id_geo)
);
alter table geo_semplades comment 'ubicación del lugar de los hechos';
/*==============================================================*/
/* table: grado_cargo */
/*==============================================================*/
create table grado_cargo
(
id_cargo int not null auto_increment comment 'identificador de la
tabla',
gra_id_cargo int comment 'identificador de la tabla',
descripcion varchar(50) not null comment 'nombre del cargo o grado',
primary key (id_cargo)
);
alter table grado_cargo comment 'grado o cargo de la persona';
/*==============================================================*/
/* table: hoja_de_responsabilidad */
/*==============================================================*/
create table hoja_de_responsabilidad
(
id_hresponsabilidad int not null auto_increment comment 'id primario de la
tabla',
id_institucion int comment 'identificacion de la tabla',
id_persona int comment 'identificador de la tabla',
id_responsable int comment 'identificacion de la tabla responsable',
fecha datetime not null comment 'fecha de hoja de
responsabilidad',
asistio char(1) not null default 'n' comment 'si los funcionarios
judcialies asistieron a la escena (s= si, n= no)',
dispuso varchar(50) comment 'nombre de la persona quien dispuso',
unidad_desc varchar(100) comment 'se registra la unidad cuando se
seleccione otro',
forma_com varchar(30) comment 'forma de comunicacion (telefono,
correo, otro)',
desc_forma_com varchar(50) comment 'describe la forma de comunicacion
(telefono se escribe número de telefono e email se escribe el correo)',
primary key (id_hresponsabilidad)
);
alter table hoja_de_responsabilidad comment 'registro de datos de la autoridad de
los responsables del lu';
/*==============================================================*/
/* table: indicios_constataciones */
/*==============================================================*/
create table indicios_constataciones
(
id_ind_cons bigint not null auto_increment,
num_indicios int not null,
tipo_indi_cons varchar(100),
color varchar(50),
marca varchar(30),
descripcion longtext,
ubicacion varchar(500),
caracteristicas longtext,
primary key (id_ind_cons)
);
alter table indicios_constataciones comment 'datos de indicios y constataciones';
/*==============================================================*/
/* table: informe_pericial */
/*==============================================================*/
create table informe_pericial
(
id_inf_pericial bigint not null auto_increment,
id_catalogo int comment 'identificador de la tabla catalogo',
id_tipo_fotografia int,
id_ind_cons bigint,
id_tipo_informe int,
lugar varchar(100),
fecha date,
num_informe bigint,
num_oficio varchar(100),
fecha_oficio date,
num_tipo_investigacion varchar(30) comment 'número del tipo de investigación',
estado char(1) not null comment 'estado del informe
p:proceso
f: finalizado
',
primary key (id_inf_pericial)
);
alter table informe_pericial comment 'datos generales del informe pericial';
/*==============================================================*/
/* table: institucion_unidad */
/*==============================================================*/
create table institucion_unidad
(
id_institucion int not null auto_increment comment 'identificacion de la
tabla',
ins_id_institucion int comment 'identificacion de la tabla',
descripcion varchar(100) not null comment 'nombre de la institución o
unidad',
primary key (id_institucion)
);
alter table institucion_unidad comment 'institucion o unidad de personas
policial - servicio u';
/*==============================================================*/
/* table: modulos */
/*==============================================================*/
create table modulos
(
id_modulo int not null auto_increment,
nombre varchar(100) not null,
fec_creacion date not null,
activo char(1) not null,
primary key (id_modulo)
);
/*==============================================================*/
/* table: permisos */
/*==============================================================*/
create table permisos
(
id_permiso int not null auto_increment,
id_modulo int,
activo char(1) not null,
primary key (id_permiso)
);
/*==============================================================*/
/* table: persona */
/*==============================================================*/
create table persona
(
id_persona int not null auto_increment comment 'identificador de la
tabla',
doc_identificacion varchar(15) not null comment 'documento de identificacion
de la persona (cedula, pasaporte)',
nombre varchar(50) not null comment 'nombre de la persona',
apellido varchar(50) not null comment 'apellido de la persona',
telefono varchar(15) comment 'telefono convencional o movil de la
persona',
sexo varchar(20) not null comment 'sexo de la persona',
nacionalidad varchar(50) not null comment 'nacionalidad de la persona',
fecha_nacimiento date comment 'fecha de nacimiento de la persona',
direccion varchar(200),
email varchar(200),
estatura decimal(3,2),
ind_dactiloscopica varchar(15),
etnia varchar(20),
primary key (id_persona)
);
alter table persona comment 'datos generales de la persona';
/*==============================================================*/
/* table: persona_cargo */
/*==============================================================*/
create table persona_cargo
(
id_percargo int not null auto_increment,
id_persona int comment 'identificador de la tabla',
id_cargo int comment 'identificador de la tabla',
id_acreditacion int,
fec_inicio date comment 'fecha inicio del cargo',
fec_fin date comment 'fecha fin del cargo',
activo bool comment 'grado activo o inactivo
a: activo
i: inactivo',
primary key (id_percargo)
);
alter table persona_cargo comment 'historial del cargo de la persona';
/*==============================================================*/
/* table: responsables */
/*==============================================================*/
create table responsables
(
id_responsable int not null auto_increment comment 'identificacion de la
tabla responsable',
id_catalogo int comment 'identificador de la tabla catalogo',
id_institucion int comment 'identificacion de la tabla',
id_percargo int,
hora date not null comment 'hora que el responsable firma',
telefono numeric(15,0) comment 'telefono del responsable',
observaciones varchar(200) comment 'observaciones del lugar de los
hechos',
filtro char(1) not null comment 'i: persona o funcionario policial
que entrega la escena al inicio de la inspección
f: transferencia de la escena por parte del personal de iot al termino
de la inspección
c: cadena de custodia
u: ucm',
unidades_escena varchar(100) comment 'para guardar la descripcion que se
seleccione (primera unidad policial en llegar, personal policial de
investigaciones, personal fiscal, equipos de socorro, victimas, testigos)
se recomienda que este catalogo se encuentre en la tabla catalogo',
primary key (id_responsable)
);
alter table responsables comment 'personas o funcionarios policiales responsables';
/*==============================================================*/
/* table: tipo_fotografia */
/*==============================================================*/
create table tipo_fotografia
(
id_tipo_fotografia int not null auto_increment,
id_catalogo int comment 'identificador de la tabla catalogo',
titulo varchar(30) not null,
descripcion varchar(200) not null,
primary key (id_tipo_fotografia)
);
alter table tipo_fotografia comment 'lugar de los hechos
cadaver: tatuajes, marcas
in';
/*==============================================================*/
/* table: tipo_informe */
/*==============================================================*/
create table tipo_informe
(
id_tipo_informe int not null auto_increment,
id_conf_inf int,
descripcion varchar(200) not null,
detalle longtext not null,
primary key (id_tipo_informe)
);
alter table tipo_informe comment 'fundamento técnico y cientifico';
/*==============================================================*/
/* table: usuario */
/*==============================================================*/
create table usuario
(
id_usuario int not null auto_increment,
id_permiso int,
id_persona int comment 'identificador de la tabla',
usuario varchar(15) not null,
password varchar(800) not null,
last_login date,
activo char(1) not null,
fec_creacion date not null,
primary key (id_usuario)
);
/*
alter table CADAVER add constraint FK_RELATIONSHIP_14 foreign key (ID_CHECKLIST)
references FORMULARIO_CHECK_LIST_IOT (ID_CHECKLIST) on delete restrict on
update restrict;
alter table CADAVER add constraint FK_RELATIONSHIP_31 foreign key (ID_CAT_CADAVER)
references CATALOGO_CADAVER (ID_CAT_CADAVER) on delete restrict on update
restrict;
alter table CADAVER add constraint FK_RELATIONSHIP_32 foreign key (ID_PERSONA)
references PERSONA (ID_PERSONA) on delete restrict on update restrict;
alter table CADENA_CUSTODIA add constraint FK_RELATIONSHIP_22 foreign key
(ID_CATALOGO)
references CATALOGO (ID_CATALOGO) on delete restrict on update restrict;
alter table CADENA_CUSTODIA add constraint FK_RELATIONSHIP_23 foreign key
(ID_CHECKLIST)
references FORMULARIO_CHECK_LIST_IOT (ID_CHECKLIST) on delete restrict on
update restrict;
alter table CADENA_CUSTODIA add constraint FK_RELATIONSHIP_24 foreign key
(ID_RESPONSABLE)
references RESPONSABLES (ID_RESPONSABLE) on delete restrict on update
restrict;
alter table CATALOGO add constraint FK_RELATIONSHIP_10 foreign key
(CAT_ID_CATALOGO)
references CATALOGO (ID_CATALOGO) on delete restrict on update restrict;
alter table CATALOGO_CADAVER add constraint FK_RELATIONSHIP_30 foreign key
(CAT_ID_CAT_CADAVER)
references CATALOGO_CADAVER (ID_CAT_CADAVER) on delete restrict on update
restrict;
alter table DETALLE_INFORME add constraint FK_RELATIONSHIP_11 foreign key
(ID_CATALOGO)
references CATALOGO (ID_CATALOGO) on delete restrict on update restrict;
alter table DETALLE_INFORME add constraint FK_RELATIONSHIP_12 foreign key
(ID_CHECKLIST)
references FORMULARIO_CHECK_LIST_IOT (ID_CHECKLIST) on delete restrict on
update restrict;
alter table FORMULARIO_CHECK_LIST_IOT add constraint FK_RELATIONSHIP_18 foreign key
(ID_GEO)
references GEO_SEMPLADES (ID_GEO) on delete restrict on update restrict;
alter table FORMULARIO_CHECK_LIST_IOT add constraint FK_RELATIONSHIP_9 foreign key
(ID_HRESPONSABILIDAD)
references HOJA_DE_RESPONSABILIDAD (ID_HRESPONSABILIDAD) on delete restrict
on update restrict;
alter table GEO_SEMPLADES add constraint FK_RELATIONSHIP_17 foreign key
(GEO_ID_GEO)
references GEO_SEMPLADES (ID_GEO) on delete restrict on update restrict;
alter table GRADO_CARGO add constraint FK_RELATIONSHIP_4 foreign key (GRA_ID_CARGO)
references GRADO_CARGO (ID_CARGO) on delete restrict on update restrict;
alter table HOJA_DE_RESPONSABILIDAD add constraint FK_RELATIONSHIP_15 foreign key
(ID_INSTITUCION)
references INSTITUCION_UNIDAD (ID_INSTITUCION) on delete restrict on update
restrict;
alter table HOJA_DE_RESPONSABILIDAD add constraint FK_RELATIONSHIP_16 foreign key
(ID_PERSONA)
references PERSONA (ID_PERSONA) on delete restrict on update restrict;
alter table HOJA_DE_RESPONSABILIDAD add constraint FK_RELATIONSHIP_39 foreign key
(ID_RESPONSABLE)
references RESPONSABLES (ID_RESPONSABLE) on delete restrict on update
restrict;
alter table INFORME_PERICIAL add constraint FK_RELATIONSHIP_26 foreign key
(ID_CATALOGO)
references CATALOGO (ID_CATALOGO) on delete restrict on update restrict;
alter table INFORME_PERICIAL add constraint FK_RELATIONSHIP_28 foreign key
(ID_TIPO_FOTOGRAFIA)
references TIPO_FOTOGRAFIA (ID_TIPO_FOTOGRAFIA) on delete restrict on update
restrict;
alter table INFORME_PERICIAL add constraint FK_RELATIONSHIP_33 foreign key
(ID_IND_CONS)
references INDICIOS_CONSTATACIONES (ID_IND_CONS) on delete restrict on update
restrict;
alter table INFORME_PERICIAL add constraint FK_RELATIONSHIP_34 foreign key
(ID_TIPO_INFORME)
references TIPO_INFORME (ID_TIPO_INFORME) on delete restrict on update
restrict;
alter table INSTITUCION_UNIDAD add constraint FK_RELATIONSHIP_3 foreign key
(INS_ID_INSTITUCION)
references INSTITUCION_UNIDAD (ID_INSTITUCION) on delete restrict on update
restrict;
alter table PERMISOS add constraint FK_RELATIONSHIP_38 foreign key (ID_MODULO)
references MODULOS (ID_MODULO) on delete restrict on update restrict;
alter table PERSONA_CARGO add constraint FK_RELATIONSHIP_25 foreign key
(ID_ACREDITACION)
references ACREDITACION (ID_ACREDITACION) on delete restrict on update
restrict;
alter table PERSONA_CARGO add constraint FK_RELATIONSHIP_5 foreign key (ID_PERSONA)
references PERSONA (ID_PERSONA) on delete restrict on update restrict;
alter table PERSONA_CARGO add constraint FK_RELATIONSHIP_6 foreign key (ID_CARGO)
references GRADO_CARGO (ID_CARGO) on delete restrict on update restrict;
alter table RESPONSABLES add constraint FK_RELATIONSHIP_19 foreign key
(ID_CATALOGO)
references CATALOGO (ID_CATALOGO) on delete restrict on update restrict;
alter table RESPONSABLES add constraint FK_RELATIONSHIP_20 foreign key
(ID_INSTITUCION)
references INSTITUCION_UNIDAD (ID_INSTITUCION) on delete restrict on update
restrict;
alter table RESPONSABLES add constraint FK_RELATIONSHIP_21 foreign key
(ID_PERCARGO)
references PERSONA_CARGO (ID_PERCARGO) on delete restrict on update restrict;
alter table TIPO_FOTOGRAFIA add constraint FK_RELATIONSHIP_29 foreign key
(ID_CATALOGO)
references CATALOGO (ID_CATALOGO) on delete restrict on update restrict;
alter table TIPO_INFORME add constraint FK_RELATIONSHIP_35 foreign key
(ID_CONF_INF)
references CONFIGURACION_INFORME (ID_CONF_INF) on delete restrict on update
restrict;
alter table USUARIO add constraint FK_RELATIONSHIP_36 foreign key (ID_PERSONA)
references PERSONA (ID_PERSONA) on delete restrict on update restrict;
alter table USUARIO add constraint FK_RELATIONSHIP_37 foreign key (ID_PERMISO)
references PERMISOS (ID_PERMISO) on delete restrict on update restrict;
*/