# ERD

The schema is normalized around a single user identity with explicit many-to-many and scoped relationship tables.

```mermaid
erDiagram
    USERS ||--o{ USER_ROLES : has
    ROLES ||--o{ USER_ROLES : assigns
    ROLES ||--o{ ROLE_PERMISSIONS : grants
    PERMISSIONS ||--o{ ROLE_PERMISSIONS : maps

    USERS ||--|| USER_PROFILES : extends
    USERS ||--o{ CLUB_MEMBERSHIPS : joins
    CLUBS ||--o{ CLUB_MEMBERSHIPS : contains
    USERS ||--o{ CLUB_STAFF_ASSIGNMENTS : manages
    CLUBS ||--o{ CLUB_STAFF_ASSIGNMENTS : administered_by

    USERS ||--o{ PARENT_CHILD_LINKS : parent
    USERS ||--o{ PARENT_CHILD_LINKS : child

    USERS ||--|| FENCER_PROFILES : extends
    WEAPONS ||--o{ FENCER_PROFILES : primary_weapon

    USERS ||--o{ COACH_CERTIFICATIONS : holds
    USERS ||--o{ REFEREE_CERTIFICATIONS : holds

    RANKING_CATEGORIES ||--o{ RANKING_SNAPSHOTS : groups
    USERS ||--o{ RANKING_SNAPSHOTS : ranked
    WEAPONS ||--o{ RANKING_CATEGORIES : filters
    AGE_GROUPS ||--o{ RANKING_CATEGORIES : filters

    LICENCE_TYPES ||--o{ LICENCE_RECORDS : defines
    USERS ||--o{ LICENCE_RECORDS : owns
    LICENCE_RECORDS ||--o{ LICENCE_STATUS_HISTORY : tracks

    CLUBS ||--o{ EVENTS : organizes
    USERS ||--o{ EVENTS : created
    EVENTS ||--o{ EVENT_ENTRIES : receives
    USERS ||--o{ EVENT_ENTRIES : enters
    USERS ||--o{ EVENT_ENTRIES : submitted_by

    USERS ||--o{ PAYMENTS : pays
    PAYMENTS ||--o{ PAYMENT_ITEMS : contains
    PAYMENT_ITEMS ||--o{ REFUNDS : refunded_by

    CONSENT_TYPES ||--o{ USER_CONSENTS : defines
    USERS ||--o{ USER_CONSENTS : subject
    USERS ||--o{ USER_CONSENTS : granted_by

    USERS ||--o{ AUDIT_LOGS : actor
```

## Key Modeling Decisions

- One account per person, many simultaneous roles
- Parent-child relationships are explicit and auditable
- Club membership is separate from club administration
- Licences are time-bound records, not a single mutable status field
- Payments are itemized so one payment can cover multiple products later
- Rankings are snapshot-based for future imports and historical comparisons

