Skip to main content

Database Overview

Database Name: asuntos_publicos The database contains four main tables for managing municipal permits and user authentication:

permisos_bebidas

Alcohol sales permits

permisos_eventos

Special event permits

permisos_publicidad

Advertising and propaganda permits

usuarios

System users and authentication

Table: permisos_bebidas

Stores permits for alcoholic beverage sales.
CREATE TABLE permisos_bebidas(
  id INT(11) NOT NULL PRIMARY KEY,
  codigo_permiso VARCHAR(200) NOT NULL,
  habilitacion DATE NOT NULL,
  vencimiento DATE NOT NULL,
  horario VARCHAR(30) NOT NULL,
  dat_confirmacion BOOLEAN NOT NULL,
  requisitor_nombre VARCHAR(50) NOT NULL,
  requisitor_apellido VARCHAR(50) NOT NULL,
  requisitor_doc VARCHAR(15) NOT NULL,
  requisitor_tlf VARCHAR(50) NOT NULL,
  requisitor_habitacion TEXT(1000) NOT NULL,
  sector_permisado TEXT(1000) NOT NULL,
  comprobante_de_pago VARCHAR(2500) NOT NULL,
  permiso_autorizado VARCHAR(2500) NOT NULL,
  creador VARCHAR(200) NOT NULL,
  editor VARCHAR(200) NOT NULL,
  fecha_creacion TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  emitido BOOLEAN NOT NULL,
  cancelado BOOLEAN NOT NULL,
  observacion TEXT(1000) NOT NULL
);

ALTER TABLE permisos_bebidas
  MODIFY id INT(11) NOT NULL AUTO_INCREMENT;
Source: database/database.sql:8-31
FieldTypeDescription
idINT(11)Primary key, auto-increment
codigo_permisoVARCHAR(200)Unique permit code
habilitacionDATEPermit start date
vencimientoDATEPermit expiration date
horarioVARCHAR(30)Operating hours
dat_confirmacionBOOLEANData confirmation flag
requisitor_nombreVARCHAR(50)Applicant first name
requisitor_apellidoVARCHAR(50)Applicant last name
requisitor_docVARCHAR(15)Applicant ID document
requisitor_tlfVARCHAR(50)Applicant phone
requisitor_habitacionTEXT(1000)Applicant address
sector_permisadoTEXT(1000)Permitted sector/location
comprobante_de_pagoVARCHAR(2500)Payment receipt file path
permiso_autorizadoVARCHAR(2500)Authorized permit file path
creadorVARCHAR(200)User who created the record
editorVARCHAR(200)User who last edited the record
fecha_creacionTIMESTAMPRecord creation timestamp
emitidoBOOLEANPermit issued status
canceladoBOOLEANPermit cancelled status
observacionTEXT(1000)Additional observations/notes

Table: permisos_eventos

Stores permits for special events.
CREATE TABLE permisos_eventos(
  id INT(11) NOT NULL PRIMARY KEY,
  codigo_permiso VARCHAR(200) NOT NULL,
  habilitacion DATE NOT NULL,
  vencimiento DATE NOT NULL,
  horario VARCHAR(30) NOT NULL,
  dat_confirmacion BOOLEAN NOT NULL,
  requisitor_nombre VARCHAR(50) NOT NULL,
  requisitor_apellido VARCHAR(50) NOT NULL,
  requisitor_doc VARCHAR(15) NOT NULL,
  requisitor_tlf VARCHAR(50) NOT NULL,
  requisitor_habitacion TEXT(1000) NOT NULL,
  sector_permisado TEXT(1000) NOT NULL,
  comprobante_de_pago VARCHAR(2500) NOT NULL,
  nombre_evento VARCHAR(76) NOT NULL,
  tipo_evento VARCHAR(100) NOT NULL,
  servicio_comida BOOLEAN NOT NULL,
  servicio_bebidas BOOLEAN NOT NULL,
  servicio_confiteria BOOLEAN NOT NULL,
  servicio_articulos_varios BOOLEAN NOT NULL,
  servicio_heladeria BOOLEAN NOT NULL,
  servicio_otros VARCHAR(100) NOT NULL,
  permiso_autorizado VARCHAR(2500) NOT NULL,
  creador VARCHAR(200) NOT NULL,
  editor VARCHAR(200) NOT NULL,
  fecha_creacion TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  emitido BOOLEAN NOT NULL,
  cancelado BOOLEAN NOT NULL,
  observacion TEXT(1000) NOT NULL
);

ALTER TABLE permisos_eventos
  MODIFY id INT(11) NOT NULL AUTO_INCREMENT;
Source: database/database.sql:34-66
Includes all base permit fields plus event-specific fields:
FieldTypeDescription
nombre_eventoVARCHAR(76)Event name
tipo_eventoVARCHAR(100)Event type
servicio_comidaBOOLEANFood service provided
servicio_bebidasBOOLEANBeverage service provided
servicio_confiteriaBOOLEANConfectionery service
servicio_articulos_variosBOOLEANMiscellaneous items service
servicio_heladeriaBOOLEANIce cream service
servicio_otrosVARCHAR(100)Other services description

Table: permisos_publicidad

Stores permits for advertising and propaganda activities.
CREATE TABLE permisos_publicidad(
  id INT(11) NOT NULL PRIMARY KEY,
  codigo_permiso VARCHAR(200) NOT NULL,
  habilitacion DATE NOT NULL,
  vencimiento DATE NOT NULL,
  horario VARCHAR(30) NOT NULL,
  dat_confirmacion BOOLEAN NOT NULL,
  requisitor_nombre VARCHAR(50) NOT NULL,
  requisitor_apellido VARCHAR(50) NOT NULL,
  requisitor_doc VARCHAR(15) NOT NULL,
  requisitor_tlf VARCHAR(50) NOT NULL,
  requisitor_habitacion TEXT(1000) NOT NULL,
  sector_permisado TEXT(1000) NOT NULL,
  publicidad_volantes INT(11) NOT NULL,
  publicidad_afiches INT(11) NOT NULL,
  publicidad_pendones INT(11) NOT NULL,
  publicidad_habladores INT(11) NOT NULL,
  publicidad_stands INT(11) NOT NULL,
  publicidad_calcomanias INT(11) NOT NULL,
  publicidad_banderolas INT(11) NOT NULL,
  publicidad_otros INT(11) NOT NULL,
  publicidad_otros_descripcion VARCHAR(100) NOT NULL,
  comentarios TEXT(1000) NOT NULL,
  comprobante_de_pago VARCHAR(2500) NOT NULL,
  permiso_autorizado VARCHAR(2500) NOT NULL,
  creador VARCHAR(200) NOT NULL,
  editor VARCHAR(200) NOT NULL,
  fecha_creacion TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  emitido BOOLEAN NOT NULL,
  cancelado BOOLEAN NOT NULL,
  observacion TEXT(1000) NOT NULL
);

ALTER TABLE permisos_publicidad
  MODIFY id INT(11) NOT NULL AUTO_INCREMENT;
Source: database/database.sql:69-103
Includes all base permit fields plus advertising-specific quantity fields:
FieldTypeDescription
publicidad_volantesINT(11)Number of flyers
publicidad_afichesINT(11)Number of posters
publicidad_pendonesINT(11)Number of banners
publicidad_habladoresINT(11)Number of shelf talkers
publicidad_standsINT(11)Number of stands
publicidad_calcomaniasINT(11)Number of stickers
publicidad_banderolasINT(11)Number of street banners
publicidad_otrosINT(11)Number of other items
publicidad_otros_descripcionVARCHAR(100)Description of other items
comentariosTEXT(1000)Additional comments

Table: usuarios

Stores system user accounts and authentication data.
CREATE TABLE usuarios(
  idDocument VARCHAR(50) NOT NULL PRIMARY KEY,
  nombre VARCHAR(50) NOT NULL,
  apellido VARCHAR(50) NOT NULL,
  cargo VARCHAR(50) NOT NULL,
  tipo_usuario VARCHAR(50) NOT NULL,
  username VARCHAR(1000) NOT NULL,
  password VARCHAR(2500) NOT NULL
);
Source: database/database.sql:106-115
FieldTypeDescription
idDocumentVARCHAR(50)Primary key - ID document number
nombreVARCHAR(50)First name
apellidoVARCHAR(50)Last name
cargoVARCHAR(50)Position/role title
tipo_usuarioVARCHAR(50)User type (Administrador, Desarrollador, etc.)
usernameVARCHAR(1000)Login username
passwordVARCHAR(2500)Hashed password (bcrypt)

Common Permit Fields

All three permit tables (permisos_bebidas, permisos_eventos, permisos_publicidad) share these base fields:
  • id: Auto-increment primary key
  • codigo_permiso: Unique permit identifier
  • habilitacion: Start date
  • vencimiento: Expiration date
  • horario: Operating hours
  • requisitor_nombre: First name
  • requisitor_apellido: Last name
  • requisitor_doc: ID document
  • requisitor_tlf: Phone number
  • requisitor_habitacion: Address
  • sector_permisado: Permitted location
  • comprobante_de_pago: Payment receipt file path
  • permiso_autorizado: Authorized permit PDF path
  • creador: User who created the permit
  • editor: User who last modified the permit
  • fecha_creacion: Creation timestamp
  • dat_confirmacion: Data confirmed
  • emitido: Permit issued
  • cancelado: Permit cancelled
  • observacion: Notes/observations

Data Relationships

1

User Authentication

Users in usuarios table authenticate and receive session
2

Permit Creation

Authenticated user creates permit in one of three permit tables
3

Audit Tracking

creador and editor fields reference the username from usuarios
4

File References

comprobante_de_pago and permiso_autorizado store file paths to uploaded/generated documents

Data Flow Example

Primary Keys & Auto-Increment

All permit tables use auto-incrementing integer IDs:
ALTER TABLE permisos_bebidas MODIFY id INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE permisos_eventos MODIFY id INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE permisos_publicidad MODIFY id INT(11) NOT NULL AUTO_INCREMENT;
The usuarios table uses the document ID as a natural primary key:
idDocument VARCHAR(50) NOT NULL PRIMARY KEY

System Architecture

Overall system design and technology stack

WebSocket Events

Real-time updates when database changes occur

Build docs developers (and LLMs) love