Database Design
Overview
PeopleHub uses PostgreSQL 17.5 on AWS RDS Multi-AZ with 140+ tables supporting the complete HRMS data model.
Database Configuration
- Engine: PostgreSQL 17.5
- Deployment: RDS Multi-AZ (automatic failover)
- Region: ap-south-1 (Mumbai)
- Encryption: Enabled (AWS KMS)
- Backup: Automated daily snapshots + point-in-time recovery (1-35 days)
- Connection: Via standard PostgreSQL protocol (port 5432)
Schema Organization
Core Entity Tables
User & Authentication:
user_master- User accounts, login credentialsrole- System rolespermission- Available permissionsrole_permission- Role-permission mapping
Company & Organization:
company_master- Company/tenant informationcustomer_master- Customers/clientsagency_master- Recruitment agenciesdata_group- Master data categoriesmaster_data- Master data values (departments, designations, etc.)
Employee Management:
user_employment_details- Employment informationuser_onboarding- Onboarding status and dataonboarding_references- Referee informationproject_allocation- Employee project assignments
Recruitment:
demand_master- Job requisitionsdemand_skill- Required skills for jobsdemand_document- Job-related documentsemployee_demand_status- Candidate applications
Leave & Attendance:
leave_application(implied) - Leave requestsleave_balance(implied) - Employee leave balancesattendance_policy(implied) - Attendance rules
Performance:
performance_cycle- Review periodsokr- Objectives and key resultsokr_goal- Individual goalssub_goal- Goal sub-tasksokr_review- Review recordsokr_change_log- Goal change historyrating_scale- Performance rating definitionsperformance_stage- Review stages
Separation:
separation_request- Resignation/termination requestsseparation_approval- Approval workflowsseparation_document- Exit-related documentsseparation_change_log- Status changesexit_survey_question,exit_survey_response,exit_survey_answer- Exit surveys
Skills & Talent:
skill- Skill definitionsskill_group- Skill groupingsskill_cluster- Higher-level skill categoriesskill_adjacency- Related skillsskill_prerequisite- Skill dependenciescertifications- Employee certificationscertification_providers- Cert issuing bodies
Policies & Configuration:
policy- Company policiescompany_holiday- Holiday calendarcompany_work_policy- Work hours and schedulesconfirmation_policy_master- Probation period rulesnotice_period_config- Notice period settings
Notifications:
notification_definition- Notification typesnotification_schedule- Scheduled notificationsnotification_recipient- Recipient rulesnotification_channel_map- Channel configuration
Workflow & Approvals:
request- Generic approval requestsrequest_approval- Approval stepsrequest_escalation_map- Escalation rules
Support:
support_ticket- Helpdesk ticketssupport_ticket_comment- Ticket discussionssupport_ticket_attachment- Attached filessupport_ticket_sla- SLA tracking
Surveys:
survey- Survey definitionsonboarding_survey_question,onboarding_survey_response,onboarding_survey_answer- Onboarding feedback
Tasks (Onboarding):
it_form_task- IT provisioning tasksfacility_admin_task- Admin tasks
Clearance (Separation):
it_noc,admin_noc,finance_noc,hr_noc,manager_noc,employee_noc- No objection certificates
Data Relationships
Primary Relationships
- User → Employee (one-to-one)
- Employee → Manager (self-referencing hierarchy)
- Company → Departments/Locations (one-to-many)
- Employee → Project Allocations (many-to-many via allocation table)
- Demand (Job) → Employee Applications (one-to-many)
- Performance Cycle → OKRs → Goals (hierarchical)
Cross-Module Relationships
- Notifications reference various entities (employee, leave, performance, etc.)
- Documents can be linked to employees, onboarding, separation, etc.
- Workflows support multiple modules (leave, separation, confirmation)
Indexing Strategy
Indexes created on:
- Primary keys (automatic)
- Foreign keys (for join performance)
- Frequently queried columns (employee status, dates)
- Unique constraints (email, employee ID)
Data Integrity
- Foreign Keys: Enforce referential integrity
- Not Null Constraints: Required fields enforced at database level
- Unique Constraints: Prevent duplicate emails, employee IDs
- Check Constraints: Validate data ranges and enums
- Triggers: Audit trail automation, timestamp updates
Schema Evolution
Migration Tool: Drizzle Kit Process:
- Define schema changes in TypeScript (Drizzle)
- Generate migration SQL
- Review and test migration
- Apply to dev → staging → production
Backward Compatibility: Maintain for at least one deployment cycle
Database Performance
Connection Pooling:
- Each Lambda maintains 10 connections
- RDS max connections configured based on instance size
Query Optimization:
- Drizzle ORM generates efficient SQL
- Indexes on join columns
- Pagination for large result sets
Monitoring:
- RDS Performance Insights enabled
- Slow query logging
- CloudWatch metrics (connections, CPU, IOPS)
Security
Access Control:
- Main API: Full access
- Candidate API: Limited to onboarding tables
- Read-only access for reporting (future)
Encryption:
- At rest: AWS KMS encryption
- In transit: SSL/TLS enforced
- Sensitive fields: Additional application-level encryption (planned for PII)
Backup & Recovery:
- Automated daily snapshots
- 30-day retention
- Cross-region backup replication (planned)
- Point-in-time recovery (PITR) up to 35 days
Planned Enhancements
- Read Replicas: For reporting and analytics
- Cross-Region Replication: For global offices (7 locations)
- Partitioning: For large tables (audit logs, notifications)
- Materialized Views: For complex reports
Schema Documentation
Full database schema diagram will be provided by the database team separately.
Related Documentation
- System Overview - Overall architecture
- Data Flow - How data moves through the system
- Core Entities - Key table descriptions
- API Reference - API endpoints