Database Architecture
The TiendaRopa database is designed to manage a clothing store’s inventory, employee operations, supplier relationships, and product catalog. The schema follows a normalized relational design pattern with clear separation of concerns. Database Name:tienda_ropaCharacter Set: UTF8MB4
Collation: utf8mb4_general_ci
Engine: InnoDB (transactional tables)
Entity Relationship Overview
The database consists of 8 core tables organized around three primary domains:Core Domains
-
Product Management
prenda(garment/item) - Central product catalogcategoria- Product categoriestalla- Size variantscolor- Color options
-
Operations & Inventory
movimiento_stock- Stock movements (entries, exits, adjustments)actualizacion- Price update history
-
Business Relationships
empleado- Employee recordsproveedor- Supplier informationregistro- Product registration linking items to suppliers
Tables Summary
prenda
Core product catalog with pricing, stock, and variant information
categoria
Product categories (Caballero, Dama, Infantil, Deportiva, Accesorios)
color
Color catalog for product variants (Negro Nocturno, Azul Marino, etc.)
talla
Size options for clothing items (ch, m, g, ech, eg)
empleado
Employee records with roles (gerente, empleado)
proveedor
Supplier contact and location information
movimiento_stock
Inventory movements tracking entries, exits, and adjustments
actualizacion
Historical record of price changes with audit trail
registro
Product registration records linking items to suppliers
Key Relationships
Primary Foreign Key Relationships
Relationship Details
| Parent Table | Child Table | Relationship | Constraint Name |
|---|---|---|---|
prenda | movimiento_stock | One-to-Many | fk_mov_prenda |
prenda | actualizacion | One-to-Many | fk_act_prenda |
prenda | registro | One-to-Many | fk_reg_prenda |
empleado | movimiento_stock | One-to-Many | fk_mov_emp |
empleado | actualizacion | One-to-Many | fk_act_emp |
empleado | registro | One-to-Many | fk_reg_emp |
proveedor | registro | One-to-Many | fk_reg_prov |
categoria | prenda | One-to-Many | fk_prenda_cat |
talla | prenda | One-to-Many | fk_prenda_talla |
color | prenda | One-to-Many | fk_prenda_color |
Design Philosophy
Normalization
The database follows Third Normal Form (3NF) principles:- Product attributes (category, size, color) are separated into lookup tables
- Transactional data (movements, updates) maintains historical integrity
- No redundant data storage except for denormalized audit fields
Audit Trail
The system maintains comprehensive audit capabilities:movimiento_stock.fecha- Timestamp of inventory changesactualizacion.precio_anterior/precio_nuevo- Price change historyregistro.fecha_registro- Product registration timestamps- All transactional tables reference
id_empleadofor accountability
Indexing Strategy
Strategic indexes improve query performance:- Primary Keys: Auto-increment integers on all tables
- Foreign Key Indexes: Automatic indexes on all FK columns
- Search Indexes:
idx_prenda_nombrefor product name searches - Composite Indexes:
idx_prenda_cat_tallafor filtered queries - Date Indexes:
idx_movimiento_fechafor temporal queries
Data Integrity
Multiple layers ensure data quality:- Foreign key constraints enforce referential integrity
NOT NULLconstraints on critical fieldsDEFAULTvalues for timestamps (CURRENT_TIMESTAMP)UNIQUEconstraint onproveedor.telefono- Decimal precision for monetary values (10,2)
Common Query Patterns
Inventory Status
Price History
Stock Movements by Employee
Database Statistics
Based on the sample data:- 5 Categories: Caballero, Dama, Infantil, Deportiva, Accesorios
- 5 Employees: Mix of gerentes and empleados
- 5 Suppliers: Local Aguascalientes providers
- 20+ Products: Various clothing items across categories
- 20+ Stock Movements: Tracking inventory changes since October 2025
- 6 Price Updates: Historical price adjustments
- 6 Registration Records: Product-supplier relationships