Schema Overview
VIP2CARS uses a relational database schema with 10 tables divided into three categories:- Core Business Tables - Client and vehicle management
- Authentication Tables - User management and sessions
- System Tables - Cache, jobs, and queue management
Core Business Tables
Clientes (Clients)
Theclientes table stores client/customer information.
Primary key - Auto-incrementing client identifier
Client’s first name(s)
Client’s last name(s)
Document/ID number - Unique constraint
Email address - Unique constraint
Phone number
Record creation timestamp
Record last update timestamp
2026_03_04_001541_create_clientes_table.php
Indexes:
- Primary Key:
id_cliente - Unique:
nro_documento - Unique:
correo
- Has many
vehiculos(one-to-many)
Vehiculos (Vehicles)
Thevehiculos table stores vehicle information linked to clients.
Primary key - Auto-incrementing vehicle identifier
License plate number - Unique constraint
Vehicle brand/manufacturer
Vehicle model
Manufacturing year (4 digits)
Foreign key referencing
clientes.id_clienteRecord creation timestamp
Record last update timestamp
2026_03_04_001547_create_vehiculos_table.php
Indexes:
- Primary Key:
id_vehiculo - Unique:
placa - Foreign Key:
id_cliente
Cascade deletion is enabled: when a client is deleted, all associated vehicles are automatically removed.
- Belongs to
clientes(many-to-one)
Authentication Tables
Users
Theusers table stores authenticated system users.
Primary key - Auto-incrementing user identifier
User’s full name
Email address - Unique constraint
Email verification timestamp
Hashed password
Remember me token for persistent login
Encrypted two-factor authentication secret
Encrypted 2FA recovery codes
Timestamp when 2FA was confirmed
Account creation timestamp
Account last update timestamp
0001_01_01_000000_create_users_table.php2025_08_14_170933_add_two_factor_columns_to_users_table.php
- Primary Key:
id - Unique:
email
Password Reset Tokens
Thepassword_reset_tokens table stores password reset tokens.
Primary key - User’s email address
Password reset token
Token creation timestamp
0001_01_01_000000_create_users_table.php
Indexes:
- Primary Key:
email
Sessions
Thesessions table stores active user sessions.
Primary key - Session identifier
Foreign key referencing
users.id - IndexedIP address of the session (supports IPv6)
Browser user agent string
Serialized session data
Unix timestamp of last activity - Indexed
0001_01_01_000000_create_users_table.php
Indexes:
- Primary Key:
id - Index:
user_id - Index:
last_activity
System Tables
Cache
Thecache table stores application cache data.
Primary key - Cache key identifier
Cached value
Unix timestamp for cache expiration - Indexed
0001_01_01_000001_create_cache_table.php
Indexes:
- Primary Key:
key - Index:
expiration
Cache Locks
Thecache_locks table manages cache lock mechanisms.
Primary key - Lock key identifier
Lock owner identifier
Unix timestamp for lock expiration - Indexed
0001_01_01_000001_create_cache_table.php
Indexes:
- Primary Key:
key - Index:
expiration
Jobs
Thejobs table stores queued jobs for background processing.
Primary key - Auto-incrementing job identifier
Queue name - Indexed
Serialized job data
Number of processing attempts
Unix timestamp when job was reserved
Unix timestamp when job becomes available
Unix timestamp of job creation
0001_01_01_000002_create_jobs_table.php
Indexes:
- Primary Key:
id - Index:
queue
Job Batches
Thejob_batches table tracks batched job execution.
Primary key - Batch identifier
Batch name
Total number of jobs in batch
Number of pending jobs
Number of failed jobs
Serialized list of failed job IDs
Batch options
Unix timestamp when batch was cancelled
Unix timestamp of batch creation
Unix timestamp when batch finished
0001_01_01_000002_create_jobs_table.php
Indexes:
- Primary Key:
id
Failed Jobs
Thefailed_jobs table stores jobs that failed processing.
Primary key - Auto-incrementing identifier
Unique identifier - Unique constraint
Database connection name
Queue name
Serialized job data
Exception stack trace
Timestamp when job failed
0001_01_01_000002_create_jobs_table.php
Indexes:
- Primary Key:
id - Unique:
uuid
Entity Relationship Diagram
The relationship between
clientes and vehiculos is one-to-many with cascade deletion.Eloquent Model Relationships
Cliente Model
Vehiculo Model
Database Conventions
- Primary Keys: Custom primary keys (
id_cliente,id_vehiculo) for business tables - Foreign Keys: Explicit foreign key constraints with cascade deletion
- Timestamps: Standard Laravel
created_atandupdated_atcolumns - Unique Constraints: Applied to business-critical fields (email, document number, license plate)
- Indexing: Strategic indexes on foreign keys and frequently queried fields
- Naming: Spanish naming for business tables, English for system tables
Migration Execution Order
0001_01_01_000000_create_users_table.php0001_01_01_000001_create_cache_table.php0001_01_01_000002_create_jobs_table.php2025_08_14_170933_add_two_factor_columns_to_users_table.php2026_03_04_001541_create_clientes_table.php2026_03_04_001547_create_vehiculos_table.php
Migrations must be run in order due to foreign key dependencies. The
clientes table must exist before vehiculos.Data Integrity
Validation Rules
Cliente:nombres: Required, string, max 255 charactersapellidos: Required, string, max 255 charactersnro_documento: Required, string, uniquecorreo: Required, email format, uniquetelefono: Required, string, max 20 characters
placa: Required, string, uniquemarca: Required, string, max 255 charactersmodelo: Required, string, max 255 charactersanio_fabricacion: Required, numeric, 4 digitsid_cliente: Required, must exist inclientestable
Cascade Operations
- Delete Cliente → All associated vehiculos are deleted automatically
- Update id_cliente → Not allowed (no cascade update defined)