Hypertext Rails

Communication Center ERD (Entity Relationship Diagram)

Relationships Overview

┌─────────────────────┐
│   AdminUser         │
│  (created_by)       │
└──────────┬──────────┘
           │
           │ 1:N
           │
┌──────────▼──────────┐      ┌─────────────────────┐
│ CommunicationTemplate│      │      Project        │
│  (template_id)       │      │                     │
└──────────┬───────────┘      └──────────┬──────────┘
           │                             │
           │ 1:N                         │ 1:N
           │                             │
┌──────────▼───────────┐      ┌─────────▼──────────┐
│ AutomationWorkflow   │      │ StakeholderProject │
│  - template_id       │      │  (join table)      │
│  - created_by_id     │      └─────────┬──────────┘
└──────────┬───────────┘                │
           │                            │ N:1
           │ 1:N                        │
           │                            │
┌──────────▼───────────┐      ┌─────────▼──────────┐
│  CommsInstance       │      │   Stakeholder      │
│  - template_id       │      │                    │
│  - created_by_id     │      │                    │
│  - automation_workflow_id│  └──────────┬─────────┘
└──────────┬───────────┘                │
           │                            │ 1:N
           │ 1:N                        │
           │                            │
┌──────────▼───────────┐      ┌─────────▼──────────┐
│  CommsDelivery       │      │      Persona       │
│  - comms_instance_id │      │                    │
│  - stakeholder_id    │◄─────┤                    │
│  - project_id        │      └──────────┬─────────┘
└──────────┬───────────┘                 │
           │                             │ 1:1
           │ 1:N                         │
           │                             │
┌──────────▼───────────┐      ┌─────────▼──────────┐
│   CommsEvent         │      │   CadenceRule      │
│   - delivery_id      │      │   (scope_type='persona')│
└──────────────────────┘      └────────────────────┘

┌─────────────────────┐
│      Project        │
└──────────┬──────────┘
           │
           │ 1:N
           │
┌──────────▼───────────┐
│   AlertTrigger       │
│   - project_id       │
└──────────────────────┘

┌─────────────────────┐      ┌─────────────────────┐
│   Stakeholder       │      │      Project        │
│   (scope_type)      │      │   (scope_type)     │
└──────────┬──────────┘      └──────────┬──────────┘
           │                            │
           │ Polymorphic                 │ Polymorphic
           │ (via scope_type/scope_ref)  │ (via scope_type/scope_ref)
           │                            │
           └──────────┬─────────────────┘
                      │
                      │ N:1
                      │
           ┌──────────▼───────────┐
           │   CadenceRule        │
           │   - scope_type       │
           │   - scope_ref        │
           │   (stakeholder/project)│
           └──────────────────────┘

┌─────────────────────┐
│      Import         │
│   (standalone)      │
└─────────────────────┘

Detailed Relationships

Parent-Child Relationships

  1. AdminUser (Parent)

    • └─> CommunicationTemplate (Child via created_by_id)
    • └─> CommsInstance (Child via created_by_id)
    • └─> AutomationWorkflow (Child via created_by_id)
  2. CommunicationTemplate (Parent)

    • └─> CommsInstance (Child via template_id)
    • └─> AutomationWorkflow (Child via template_id)
  3. AutomationWorkflow (Parent)

    • └─> CommsInstance (Child via automation_workflow_id)
  4. CommsInstance (Parent)

    • └─> CommsDelivery (Child via comms_instance_id)
  5. CommsDelivery (Parent)

    • └─> CommsEvent (Child via delivery_id)
  6. Stakeholder (Parent)

    • └─> StakeholderProject (Child via stakeholder_id)
    • └─> CommsDelivery (Child via stakeholder_id)
    • └─> CadenceRule (Child via polymorphic scope_type='stakeholder')
  7. Project (Parent)

    • └─> StakeholderProject (Child via project_id)
    • └─> AlertTrigger (Child via project_id)
    • └─> CommsDelivery (Child via project_id)
    • └─> CadenceRule (Child via polymorphic scope_type='project')
  8. Persona (Parent)

    • └─> Stakeholder (Child via persona field)
    • └─> CadenceRule (Child via polymorphic scope_type='persona')
  9. Import (Standalone - no parent/child relationships)

Foreign Key Summary

Child Table Foreign Key Parent Table Relationship Type
comms_instances template_id communication_templates Belongs To
comms_instances created_by_id admin_users Belongs To
comms_instances automation_workflow_id automation_workflows Belongs To
automation_workflows template_id communication_templates Belongs To
automation_workflows created_by_id admin_users Belongs To
comms_deliveries comms_instance_id comms_instances Belongs To
comms_deliveries stakeholder_id stakeholders Belongs To
comms_deliveries project_id projects Belongs To
comms_events delivery_id comms_deliveries Belongs To
stakeholder_projects stakeholder_id stakeholders Belongs To
stakeholder_projects project_id projects Belongs To
alert_triggers project_id projects Belongs To
stakeholders persona personas (via name) Belongs To
cadence_rules scope_ref (polymorphic) stakeholders/projects/personas Polymorphic

Notes

  • CadenceRule uses a polymorphic relationship via scope_type and scope_ref instead of traditional foreign keys. Supported scope types: 'persona', 'stakeholder', 'project', 'multi_project'
  • Import is a standalone table with no foreign key relationships
  • StakeholderProject is a join table creating a many-to-many relationship between Stakeholders and Projects
  • AutomationWorkflow enables automated communication scheduling and triggering:
    • Scheduled workflows: Use schedule_config JSON field for frequency/time settings, tracked via next_run_at timestamp
    • Trigger-based workflows: Use trigger_config JSON field for trigger events (events array) and last_trigger_check_at timestamp
    • Both types can create CommsInstances automatically when conditions are met
  • CommsDelivery can be associated with both a Stakeholder and a Project, allowing project-level delivery tracking
  • Persona provides default cadence rules that apply to all stakeholders with that persona, with individual stakeholder overrides possible