Geographic Location
Data Entity
Description
Stores geographic position and address data for peer mentors, used for map visualization and assignment matching by proximity. Each record represents a peer mentor's registered service area or home location, enabling coordinators to find suitable peer mentors for assignments based on distance.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Primary key | PKrequiredunique |
peer_mentor_profile_id |
uuid |
Foreign key to peer_mentor_profiles — each location record belongs to exactly one peer mentor profile | required |
label |
string |
Human-readable label for this location entry, e.g. 'Home', 'Service Area', 'Primary Location' | - |
latitude |
decimal |
WGS-84 latitude in decimal degrees | required |
longitude |
decimal |
WGS-84 longitude in decimal degrees | required |
address_line1 |
string |
Street address, first line | - |
address_line2 |
string |
Street address, second line (apartment, floor, etc.) | - |
postal_code |
string |
Norwegian postal code (postnummer), 4 digits | - |
city |
string |
City or municipality name | - |
county |
string |
Norwegian county (fylke) name | - |
country_code |
string |
ISO 3166-1 alpha-2 country code, defaults to 'NO' | required |
service_radius_km |
decimal |
The radius in kilometers within which the peer mentor is willing to travel for assignments. Used by assignment matching. | - |
location_type |
enum |
Whether this is the peer mentor's home address or a declared service area center point | required |
geocode_source |
enum |
How the lat/lng coordinates were obtained | required |
geocode_accuracy |
enum |
Accuracy level of the geocoded coordinates | - |
is_primary |
boolean |
Whether this is the peer mentor's primary location used for map display and default matching | required |
is_public |
boolean |
Whether this location is visible to coordinators on the map. Peer mentor can opt out of map visibility. | required |
created_at |
datetime |
Timestamp when the location record was created | required |
updated_at |
datetime |
Timestamp of last update | required |
Database Indexes
idx_geographic_locations_peer_mentor_profile_id
Columns: peer_mentor_profile_id
idx_geographic_locations_primary
Columns: peer_mentor_profile_id, is_primary
idx_geographic_locations_public
Columns: is_public
idx_geographic_locations_lat_lng
Columns: latitude, longitude
idx_geographic_locations_postal_code
Columns: postal_code
Validation Rules
valid_coordinates
error
Validation failed
valid_norwegian_postal_code
error
Validation failed
coordinates_within_norway
warning
Validation failed
service_radius_positive
error
Validation failed
Business Rules
single_primary_location_per_mentor
Each peer mentor profile must have at most one location record with is_primary = true. When a new primary location is set, any existing primary is demoted.
map_visibility_respects_opt_out
Peer mentors with is_public = false must not appear on the coordinator map view. Location coordinates must not be returned in any map API response for opted-out mentors.
location_required_for_matching
Assignment matching by geography can only include peer mentors who have at least one public primary location with valid lat/lng. Mentors without a location are excluded from matching results.
service_radius_defaults_to_organization_default
If service_radius_km is not set, the assignment matching engine uses the organization's default radius setting from organization_settings.
paused_mentors_hidden_from_map
Peer mentors with an active pause status must not appear on the geographic map view, regardless of is_public setting.