Demo All names and records here are made up, and the data resets every night. Please do not enter real personal information. ← Back to Find Care Scotland software · All software
Care Core

Documentation › Reference › Data model

Data model

The tables and how they relate.

Care Core uses one MySQL (or MariaDB) database with real foreign keys. Every table that holds an organisation’s data carries organisation_id. Public identifiers are UUIDs; internal keys are integers. The canonical definition is database/schema.sql.

The shape of it

organisations
 ├─ organisation_modules          which modules are switched on
 ├─ persons                        one permanent identity per human
 │    ├─ person_profiles           1:1  address, emergency contact, NI/bank (encrypted), photo, signature
 │    ├─ employments               a stint of work: dates, job, contract, hours, line manager
 │    │    ├─ employment_changes   what changed in a move, and from when
 │    │    └─ employment_details   1:1  TUPE, working time, visa, apprenticeship, leave
 │    ├─ support_episodes          a period of receiving support
 │    │    ├─ care_needs
 │    │    └─ person_contacts
 │    ├─ team_assignments          who is in which team, valid_from / valid_to
 │    ├─ key_worker_assignments    supported person ↔ staff person, valid_from / valid_to
 │    ├─ registrations, supervisions, appraisals, learning_records
 │    ├─ profile_changes           staff requests waiting for approval
 │    ├─ tasks                     joiner / mover / leaver / reassign work
 │    └─ users                     a login (access_ends_on, oidc_subject)
 ├─ teams                          hierarchy (parent_team_id), staff_only
 ├─ checklist_templates / _items   what creates tasks
 ├─ outbox_events → webhook_deliveries ← webhook_endpoints
 ├─ audit_log                      append only
 └─ scim_tokens, login_attempts, schema_migrations

The tables

TableHoldsKey points
organisationsEach tenant.Everything else belongs to one.
job_roles, job_role_requirementsA job role and the checks needed before someone can start in it.Title, code, description, reporting line (to another role), usual team, contract, hours, grade; each check is required or optional.
vacanciesA post (or several) to fill in a role.Reference, role, team, line manager, posts, status (draft, open, filled, closed).
applications, application_checksA candidate for a vacancy, and their checks.Candidate details, stage, interview and offer dates; linked to a person and an employment once hired.
personsA human, once.Names, date of birth, sex, NHS/CHI number, email, phone, employment status, GP practice, home address in parts, notes. Never deleted.
person_profilesPersonal details that belong to the person.National Insurance and bank columns hold encrypted text.
employmentsOne stint of work.start_date, end_date (last day), job title, contract type, hours, line_manager_person_id, employee_ref (unique per organisation), leaving reason. A rehire is a new row.
employment_changesHistory of a move.Field, from value, to value, effective date.
employment_detailsTerms of an employment.One row per employment: TUPE, working time, apprenticeship, visa, leave.
teamsServices and teams.Parent, kind, staff_only, active.
team_assignmentsMembership stints.valid_from, valid_to, role, primary flag, source.
support_episodesPeriods of support.Start and end dates, reference, NHS number, local authority reference.
care_needsNeeds for a person supported.Category, description, severity, review date, ended_on.
person_contactsContacts.Type, label, value, primary.
key_worker_assignmentsKey worker links.Supported person, staff person, role label, valid_from, valid_to.
registrations, supervisions, appraisals, learning_recordsCompliance records.Belong to the person.
profile_changesSelf-service requests.Field, label, current and proposed value (encrypted for sensitive fields), status (pending, approved, rejected, withdrawn), reviewer, reason.
usersLogins.Unique email, password hash (null for Microsoft-only), role, status, access_ends_on, invitation token hash, oidc_subject.
checklist_templates, checklist_template_itemsWhat creates tasks.Per kind (joiner, mover, leaver).
tasksWork to do.Kind, title, due date, owner role, status (open, done, skipped).
outbox_eventsEvents.The signed-and-sent payload, fanned_out_at.
webhook_endpoints, webhook_deliveriesWebhooks.Address, secret, event filter, active; per-delivery attempts, status and last error.
audit_logWho did what.Append-only.
scim_tokensSCIM credentials.Only a SHA-256 hash of each token.
api_keysAPI keys.Prefix, SHA-256 hash, scopes, allowed addresses, rate limit, expiry, last use.
api_rate, api_idempotencyAPI rate limiting and replay protection.Per key per minute; stored results of POSTs with an Idempotency-Key, kept 24 hours.
login_attemptsFailed sign-ins.For the lock-out rule.
schema_migrationsWhich upgrades have run.See Day-to-day operations.

The period rule

For employments, support_episodes, team_assignments and key_worker_assignments, a row is active on date D when start <= D AND (end IS NULL OR end >= D). The end date is the last day, inclusive. All queries use this one rule.

Deletion

Lifecycle processes never delete rows. They end them. Rows are removed only by a few explicit actions: removing a compliance record, removing a contact, removing a checklist item, and (by foreign key) deleting an entire organisation or person in the database.

Upgrading the schema

Numbered files in database/migrations/ are applied once each, in order, by php scripts/migrate.php. A new installation builds from schema.sql, which already contains them all. See operations.