Core Tables
This page documents the main tables in the database with their complete schemas and relationships.User & Authentication
users
users
Core user account table with profile information and references.Key Relationships:
- References
licensefor driver’s license information - References
user_statusfor account status - References
rolesfor primary role assignment - References
departmentsfor organizational structure
roles
roles
System roles defining permission groups.Standard Roles:
admin- System administratorvendedor- Sales representativegerente- Managercliente- Customerrecepcionista- Receptionistsupervisor- Supervisoroperaciones- Operationscobros- Collections
user_access_log
user_access_log
Tracks user login sessions with device and location information.
Customer Management
customers
customers
Master customer table with core business entity information.Indexes:
idx_customers_tax_idontax_ididx_customers_nameonnameidx_customers_legal_nameonlegal_name
customer_addresses
customer_addresses
Multiple addresses per customer with type designation.
customer_contacts
customer_contacts
Contact persons associated with customers.
company_name
company_name
Legal entities (razones sociales) for customer billing.Unique Constraint:
- Only one
is_default = TRUEpercustomer_id
Service Requests
service_requests
service_requests
Main service request table with core information.
request_sanitarios
request_sanitarios
Additional data for sanitarios (portable toilet) service requests.
request_fosas
request_fosas
Additional data for fosas (septic tank) service requests.
service_request_quotations
service_request_quotations
Generated quotations for service requests.
Products
products
products
Product catalog with automatic SKU generation.Automatic SKU Generation:
Products automatically receive a SKU based on their category prefix (e.g.,
QUIM-0001, ACC-0023).product_categories
product_categories
Hierarchical product categories with SKU prefix assignment.Standard Categories:
CABIN- CabinasQUIM- QuímicosACC- AccesoriosREP- RepuestosEQUI- EquiposCONS- ConsumiblesSERV- Servicios adicionales
Payments
payments
payments
Payment records with OCR support and validation workflow.
File Storage
storage_files
storage_files
Centralized file metadata with S3 storage references.Unique Constraint:
(bucket_name, object_key)must be unique
Notifications
notifications
notifications
Multi-channel notification system.
Table Relationships
Key foreign key relationships in the database:Next Steps
Stored Procedures
Database functions and triggers
Schema Overview
High-level architecture