37769-vm/ERD.md
2026-01-24 20:50:44 +00:00

3.0 KiB

Entity Relationship Diagram

erDiagram
    Tenant ||--o{ TenantUserRole : has
    Tenant ||--o{ InteractionType : defines
    Tenant ||--o{ DonationMethod : defines
    Tenant ||--o{ ElectionType : defines
    Tenant ||--o{ EventType : defines
    Tenant ||--o{ Voter : belongs_to
    Tenant ||--o{ Event : organizes

    User ||--o{ TenantUserRole : assigned_to

    Voter ||--o{ VotingRecord : has
    Voter ||--o{ EventParticipation : participates
    Voter ||--o{ Donation : makes
    Voter ||--o{ Interaction : receives
    Voter ||--o{ VoterLikelihood : has

    Event ||--o{ EventParticipation : includes
    EventType ||--o{ Event : categorizes

    InteractionType ||--o{ Interaction : categorizes
    DonationMethod ||--o{ Donation : categorizes
    ElectionType ||--o{ VoterLikelihood : categorizes

    Tenant {
        int id PK
        string name
        string slug
        text description
        datetime created_at
    }

    User {
        int id PK
        string username
        string email
        string first_name
        string last_name
    }

    TenantUserRole {
        int id PK
        int user_id FK
        int tenant_id FK
        string role
    }

    InteractionType {
        int id PK
        int tenant_id FK
        string name
        boolean is_active
    }

    DonationMethod {
        int id PK
        int tenant_id FK
        string name
        boolean is_active
    }

    ElectionType {
        int id PK
        int tenant_id FK
        string name
        boolean is_active
    }

    EventType {
        int id PK
        int tenant_id FK
        string name
        boolean is_active
    }

    Voter {
        int id PK
        int tenant_id FK
        string voter_id
        string first_name
        string last_name
        text address
        string address_street
        string city
        string state
        string zip_code
        string county
        decimal latitude
        decimal longitude
        string phone
        string email
        string district
        string precinct
        date registration_date
        boolean is_targeted
        string candidate_support
        string yard_sign
        datetime created_at
    }

    VotingRecord {
        int id PK
        int voter_id FK
        date election_date
        string election_description
        string primary_party
    }

    Event {
        int id PK
        int tenant_id FK
        date date
        int event_type_id FK
        text description
    }

    EventParticipation {
        int id PK
        int event_id FK
        int voter_id FK
        string participation_type
    }

    Donation {
        int id PK
        int voter_id FK
        date date
        int method_id FK
        decimal amount
    }

    Interaction {
        int id PK
        int voter_id FK
        int type_id FK
        date date
        string description
        text notes
    }

    VoterLikelihood {
        int id PK
        int voter_id FK
        int election_type_id FK
        string likelihood
    }