Core Tables
The database consists of 6 primary tables:Incidents
Main incident records with status tracking
Users (Profiles)
User profiles with role-based permissions
Rooms
Hotel room codes for incident location
Areas
Department/area assignments for incidents
Sessions
Guest access sessions with QR codes
Resolutions
Incident resolution records with evidence
Database Relationships
Key Design Patterns
Role-Based Access
The system supports three user roles:- guest: Hotel guests who report incidents via temporary sessions
- empleado: Staff members assigned to specific areas
- admin: Administrators who manage users and sessions
Status Workflow
Incidents progress through defined statuses:pendiente- Initially reported, awaiting assignmentrecibida- Accepted by staff memberen_progreso- Staff is actively working on itresuelta- Completed with resolution details
Guest Access Model
Guests access the system through temporary sessions:- Sessions are created by admins with expiration dates
- Each session generates a unique access code
- Sessions are tied to specific room codes
- QR codes enable quick mobile access
Query Examples
Fetch Incident with Related Data
Load Area-Specific Incidents
Create Guest Session
Storage Buckets
The app uses Supabase Storage for incident evidence:- incident-evidence: Stores photos uploaded when resolving incidents
- Path format:
{user_id}/{timestamp}.{extension}
Next Steps
Incidents Table
Detailed schema for incident records
Users Table
User profile and authentication schema