Data Structure & Relationships
HRS uses a relational data model with well-defined entities and relationships. This page explores the complete data structure, field definitions, and entity relationships.Core Entities
The HRS system has five primary entities:Alumno
Students enrolled in the school
Instructor
Teaching staff members
Caballo
Horses (school-owned and private)
Clase
Scheduled riding classes
PersonaPrueba
Trial class participants
User
System users and accounts
Entity Relationship Diagram
Detailed Entity Definitions
Alumno (Student)
Fromsrc/lib/api.ts:12:
Primary key - Unique identifier for the student
DNI (Documento Nacional de Identidad)
- Unique national ID number
- Numbers only, no punctuation (e.g., “12345678”)
- System validates for duplicates in real-time
- Acts as a unique constraint in database
Student’s first name(s)
Student’s last name(s)
Birth date in ISO format (YYYY-MM-DD)
- Used for age calculation
- Required for insurance purposes
Area code for phone number
- Typically “549” for Argentina
Phone number without prefix
- Format: numbers only (e.g., “221234567”)
- System automatically adds +549 prefix
- Final format: +549221234567
Email address (optional but recommended)
- Used for communications
- Can be used for account creation
Enrollment date in ISO format
- Automatically set to current date on creation
- Tracks when student joined school
Monthly lesson plan
- Valid values: 4, 8, 12, 16
- Determines student’s monthly quota
Indicates if student owns a horse
true: Student has private horsefalse: Student uses school horses
Account status
true: Active student (can book classes)false: Inactive (cannot book, but history preserved)
Foreign key to assigned/owned horse
null: No assigned horsenumber: Horse ID referenceCaballo: Populated horse object in detailed queries
Boarding type - one of:
"SIN_CABALLO": No assigned horse"RESERVA_ESCUELA": Reserved school horse"CABALLO_PROPIO": Private horse
Boarding quota (required if tipoPension is not SIN_CABALLO)
"ENTERA": Full boarding"MEDIA": Half boarding"TERCIO": Third boardingnull: Not applicable (SIN_CABALLO)
Instructor
Fromsrc/lib/api.ts:37:
Primary key - Unique instructor identifier
Unique national ID number (validated for duplicates)
Instructor’s first name(s)
Instructor’s last name(s)
Birth date in ISO format (YYYY-MM-DD)
Phone area code (e.g., “549”)
Phone number (system adds +549 prefix)
Email address (optional)
Employment status
true: Active instructor (can be assigned classes)false: Inactive (history preserved)
Hex color code for calendar identification
- 7 predefined colors available
- Used as background in calendar cells
- Helps visual distinction of classes
- Example: “#FF6B6B”, “#4ECDC4”, “#45B7D1”
Caballo (Horse)
Fromsrc/lib/api.ts:50:
Primary key - Unique horse identifier
Horse’s name
Horse ownership type:
"ESCUELA": School-owned horse (available to all students)"PRIVADO": Privately-owned horse (only for owner)
src/types/enums.ts:15:Availability status
true: Can be scheduled for classesfalse: Not available (injured, retired, etc.)
Array of associated students (populated in detailed queries)
- For PRIVADO: Students who own the horse
- For ESCUELA: Students who have reserved the horse
Clase (Class)
Fromsrc/lib/api.ts:58:
Primary key - Unique class identifier
Class specialty type:
"EQUITACION": Standard riding lessons"ADIESTRAMIENTO": Dressage/training"EQUINOTERAPIA": Equine therapy"MONTA": Open riding (auto-assigns placeholder student ID 1)
src/types/enums.ts:3:Class date in ISO format (YYYY-MM-DD)
Start time in 24-hour format (HH:mm)
- Example: “09:00”, “14:30”, “18:00”
- Must be on 30-minute intervals
Duration in minutes
- Valid values: 30, 60
- Default: 30
- 60-minute classes occupy two time slots
Class state:
"PROGRAMADA": Scheduled (default for new classes)"INICIADA": Started/in progress"COMPLETADA": Successfully completed"CANCELADA": Cancelled"ACA": Absence with Advance Notice"ASA": Absence without Advance Notice
src/types/enums.ts:8:Optional notes/comments about the class
Foreign key to Alumno
null: For trial classes with PersonaPruebanumber: Student ID for regular classes- For MONTA specialty: ID 1 (placeholder student)
Foreign key to PersonaPrueba
null: Regular class with enrolled studentnumber: Trial class for prospective student
Foreign key to Instructor (always required)
Foreign key to Caballo (always required)
Combined date-time string (computed field)
Trial class flag
true: This is a trial/demo classfalseorundefined: Regular class
First name of trial person (if trial class)
Last name of trial person (if trial class)
Full name of trial person (computed field)
ClaseDetallada (Detailed Class)
Fromsrc/lib/api.ts:77:
Clase with populated relationships:
- alumno: Full Alumno object (if not trial class)
- personaPrueba: Full PersonaPrueba object (if trial class)
- instructor: Full Instructor object
- caballo: Full Caballo object
PersonaPrueba (Trial Person)
Fromsrc/lib/api.ts:30:
Primary key - Unique identifier
First name of trial participant
Last name of trial participant
Registration date (ISO format)
- Automatically set to current date
User
Fromsrc/services/authService.ts:5:
Primary key - Unique user identifier
Unique username for login (unique constraint)
Email address (unique constraint, must be in whitelist)
Hashed password (never sent to client)
User role (e.g., “admin”, “instructor”, “receptionist”)
Account active status
Account creation date (ISO format)
URL to user’s profile picture
Type Enums
Fromsrc/types/enums.ts:
Relationships
One-to-Many Relationships
Alumno → Clase
Alumno → Clase
One student can have many classes
- A student can be enrolled in multiple classes
- Each class has exactly one student (or PersonaPrueba)
- Student can be deleted if they have no classes
- Cascade: Typically preserve classes when student becomes inactive
Instructor → Clase
Instructor → Clase
One instructor can teach many classes
- An instructor teaches multiple classes
- Each class must have exactly one instructor
- Cannot delete instructor with scheduled classes
- Cascade: Typically prevent deletion or reassign classes
Caballo → Clase
Caballo → Clase
One horse can be used in many classes
- A horse can be scheduled for multiple classes
- Each class uses exactly one horse
- Cannot delete horse with scheduled classes
- Cascade: Prevent deletion or mark unavailable
PersonaPrueba → Clase
PersonaPrueba → Clase
One trial person can have multiple trial classes
- Trial participants can try different specialties
- System validates no duplicate trials per specialty
- Trial classes marked with
esPrueba: true
One-to-One or Many-to-One Relationships
Alumno → Caballo (Owner/Reservation)
Alumno → Caballo (Owner/Reservation)
Student can own/reserve one horseScenarios:
- SIN_CABALLO:
caballoPropio = null- No assigned horse
- School assigns available horse per class
- RESERVA_ESCUELA:
caballoPropio = ID of ESCUELA horse- Student reserves specific school horse
- Horse type must be “ESCUELA”
- Other students can still use if not reserved
- CABALLO_PROPIO:
caballoPropio = ID of PRIVADO horse- Student owns the horse
- Horse type must be “PRIVADO”
- Only owner can use this horse
Caballo → Alumno (Owners)
Caballo → Alumno (Owners)
Horse can have multiple owner associations
- PRIVADO horses: Usually one owner
- ESCUELA horses: Can have multiple students with reservations
- Reverse relationship of Alumno.caballoPropio
Search Filter Interfaces
Fromsrc/lib/api.ts:85:
AlumnoSearchFilters
InstructorSearchFilters
CaballoSearchFilters
ClaseSearchFilters
Data Validation Rules
Business Rules
Field Constraints
Phone Numbers:- Input format: Numbers only (e.g., “221234567”)
- System adds: “+549” prefix
- Final format: “+549221234567”
- Format: ISO 8601 (YYYY-MM-DD)
- Examples: “2026-03-04”, “2025-12-31”
- Format: 24-hour (HH:mm)
- Must be on 30-minute intervals
- Range: 09:00 to 18:30
- Examples: “09:00”, “14:30”, “18:00”
- Must exactly match defined enum values
- Case-sensitive
- No custom values allowed
API Response Formats
Success Response
Error Response
Fromsrc/lib/api.ts:128:
Data Flow Examples
Creating a Student with Private Horse
Scheduling a Class
Understanding the data structure is essential for effectively using and extending the HRS system. All relationships are carefully designed to maintain data integrity while providing flexibility for various school scenarios.