Skip to main content
The application uses a single MySQL database named hotel_guevarini_publico. The schema is defined in base_de_datos.sql at the project root and includes 5 tables with seed data for testing.

Entity Relationships

roles ──< usuarios ──< clientes ──< reservaciones

                    habitaciones ────────┘
  • A role (roles) is assigned to one or many users (usuarios).
  • A user (usuarios) may optionally be linked to one client record (clientes). Deleting a user sets the client’s id_usuario to NULL.
  • A client (clientes) can have many reservations (reservaciones). Deleting a client cascades and removes their reservations.
  • A room (habitaciones) can appear in many reservations (reservaciones). Deleting a room cascades and removes its reservations.

Tables

Stores the two role types available in the system.
ColumnTypeConstraints
id_rolINTAUTO_INCREMENT, PRIMARY KEY
nombre_rolVARCHAR(50)NOT NULL
Seed data
id_rolnombre_rol
1Administrador
2Cliente
CREATE TABLE roles (
    id_rol INT AUTO_INCREMENT PRIMARY KEY,
    nombre_rol VARCHAR(50) NOT NULL
);

INSERT INTO roles (nombre_rol) VALUES
('Administrador'),
('Cliente');
Stores login credentials and account verification state for every user.
ColumnTypeConstraints
id_usuarioINTAUTO_INCREMENT, PRIMARY KEY
nombre_completoVARCHAR(100)NOT NULL
correoVARCHAR(100)NOT NULL, UNIQUE
passwordVARCHAR(255)NOT NULL — bcrypt hash
id_rolINTNOT NULL, FK → roles(id_rol)
verificadoTINYINT(1)DEFAULT 0
token_verificacionVARCHAR(255)nullable
token_recuperacionVARCHAR(255)nullable
expiracion_token_recuperacionDATETIMEnullable
Passwords are stored and compared as plain text in this system — no hashing is applied. The VARCHAR(255) column is sized for a future bcrypt implementation but is not currently used. Do not use real or sensitive passwords. The system is intended for local development and learning purposes only.
CREATE TABLE usuarios (
    id_usuario INT AUTO_INCREMENT PRIMARY KEY,
    nombre_completo VARCHAR(100) NOT NULL,
    correo VARCHAR(100) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    id_rol INT NOT NULL,
    verificado TINYINT(1) DEFAULT 0,
    token_verificacion VARCHAR(255) DEFAULT NULL,
    token_recuperacion VARCHAR(255) DEFAULT NULL,
    expiracion_token_recuperacion DATETIME DEFAULT NULL,
    FOREIGN KEY (id_rol) REFERENCES roles(id_rol)
);
Stores guest contact information. A client record can exist independently of a user account.
ColumnTypeConstraints
id_clienteINTAUTO_INCREMENT, PRIMARY KEY
id_usuarioINTnullable, FK → usuarios(id_usuario) ON DELETE SET NULL
nombre_completoVARCHAR(100)NOT NULL
telefonoVARCHAR(20)NOT NULL
estadoENUM('Activo', 'Inactivo')DEFAULT 'Activo'
Seed data
nombre_completotelefonoestado
Carlos López555-3841Activo
Ana Martínez555-7734Inactivo
CREATE TABLE clientes (
    id_cliente INT AUTO_INCREMENT PRIMARY KEY,
    id_usuario INT DEFAULT NULL,
    nombre_completo VARCHAR(100) NOT NULL,
    telefono VARCHAR(20) NOT NULL,
    estado ENUM('Activo', 'Inactivo') DEFAULT 'Activo',
    FOREIGN KEY (id_usuario) REFERENCES usuarios(id_usuario) ON DELETE SET NULL
);
Tracks every room in the hotel, its category, nightly price, and availability status.
ColumnTypeConstraints
id_habitacionINTAUTO_INCREMENT, PRIMARY KEY
numeroVARCHAR(10)NOT NULL, UNIQUE
tipoVARCHAR(50)NOT NULL
precioDECIMAL(10,2)NOT NULL
estadoENUM('Disponible', 'Ocupada', 'Mantenimiento')DEFAULT 'Disponible'
Seed data
numerotipoprecioestado
101ASencilla50.00Disponible
105BDoble85.00Ocupada
201CSuite150.00Mantenimiento
302ADoble85.00Disponible
CREATE TABLE habitaciones (
    id_habitacion INT AUTO_INCREMENT PRIMARY KEY,
    numero VARCHAR(10) NOT NULL UNIQUE,
    tipo VARCHAR(50) NOT NULL,
    precio DECIMAL(10,2) NOT NULL,
    estado ENUM('Disponible', 'Ocupada', 'Mantenimiento') DEFAULT 'Disponible'
);
Records each reservation linking a client to a room for a specific date range.
ColumnTypeConstraints
id_reservaINTAUTO_INCREMENT, PRIMARY KEY
codigoVARCHAR(20)NOT NULL, UNIQUE
id_clienteINTNOT NULL, FK → clientes(id_cliente) ON DELETE CASCADE
id_habitacionINTNOT NULL, FK → habitaciones(id_habitacion) ON DELETE CASCADE
fecha_entradaDATENOT NULL
fecha_salidaDATENOT NULL
estadoENUM('Confirmada', 'Pendiente', 'Cancelada')DEFAULT 'Pendiente'
Seed data
codigoid_clienteid_habitacionfecha_entradafecha_salidaestado
RES-9912122026-03-202026-03-25Confirmada
RES-9934232026-04-102026-04-15Pendiente
CREATE TABLE reservaciones (
    id_reserva INT AUTO_INCREMENT PRIMARY KEY,
    codigo VARCHAR(20) NOT NULL UNIQUE,
    id_cliente INT NOT NULL,
    id_habitacion INT NOT NULL,
    fecha_entrada DATE NOT NULL,
    fecha_salida DATE NOT NULL,
    estado ENUM('Confirmada', 'Pendiente', 'Cancelada') DEFAULT 'Pendiente',
    FOREIGN KEY (id_cliente) REFERENCES clientes(id_cliente) ON DELETE CASCADE,
    FOREIGN KEY (id_habitacion) REFERENCES habitaciones(id_habitacion) ON DELETE CASCADE
);

Importing the Schema

Run the following command from a MySQL client to create the database, all tables, and seed records in one step:
mysql -u root -p < base_de_datos.sql
Or import base_de_datos.sql through your GUI client (phpMyAdmin, DBeaver, MySQL Workbench).
The seed user passwords (12345) are stored as plain text, and the system compares passwords as plain text at runtime — no hashing is applied. Only use test passwords in local environments. Never deploy this system to a public URL without adding proper password hashing first.