Skip to content

Commit

Permalink
Add Users and Memberships to the ERD
Browse files Browse the repository at this point in the history
  • Loading branch information
ollietreend committed Dec 15, 2023
1 parent c0c4398 commit 2098182
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ erDiagram
string trn FK "Primary key for people in DQT"
}
User {
uuid id PK
string email UK
}
Membership {
uuid id PK
uuid user_id FK
string organisation_type FK "Polymorphic association with School or Provider"
string organisation_id FK "Polymorphic association with School or Provider"
enum service "Placements or Claims"
}
GiasSchool {
uuid id PK
string urn UK "Unique identifier for Schools"
Expand All @@ -83,6 +96,10 @@ erDiagram
School ||--|{ Claim : "has many"
Claim }|--|{ MentorTraining : "has and belongs to many"
User ||--|{ Membership : "has many"
Membership }|--o| Provider : "belongs to (polymorphic)"
Membership }|--o| School : "belongs to (polymorphic)"
```

## Onboarding Schools and Providers into the services
Expand Down Expand Up @@ -120,3 +137,18 @@ Onboarded Providers will have a record in the `providers` table.
Providers are only onboarded into the School Placements service, because this is the only service Provider Users will need to sign in to. Providers will not sign in to the Track & Pay service.

Both services will query the Provider endpoints on the [Teacher Training Courses API](https://api.publish-teacher-training-courses.service.gov.uk/docs/api-reference.html) to retrieve and display information about a Provider given its Accredited Provider ID.

## Users and Organisations

Users are members of Organisations.

Organisation is a polymorphic association which represents either a School or a Provider.

Users can have many Memberships with Organisations (Schools or Providers). Membership acts as the join table between Users and Schools/Providers.

Memberships are also scoped by `service`, which will be either `"placements"` or `"claims"`. This means that, for example, a User belonging to a School in the Track & Pay service won't be able to login to the School Placements service and manage Placements for that same School. They'll need to be added to the User list of each service independently if they need to login to both.

We can therefore define the following composite indexes:

- `[service, user_id]`
- `[organisation_type, organisation_id]`

0 comments on commit 2098182

Please sign in to comment.