Console · POI and Route Planner · v2 → v2.1

Data model review

Entity relationships

core.Property is the core asset; mdm holds master data; dbo holds Route Planner transactions. Deployed by database/sql/01_AGRAAJA_POI_RoutePlanner_v2.sql.

Master data · mdm

Master data entities: Property, POI, category, type, association and POI detail tables

Route Planner · dbo

Route Planner entities: route plan, stops, legs, execution and stop events

Kept from v2

  • Property is the core business asset (core.Property, PropertyGUID); no Hotel entity and no copy of Property.
  • mdm.POI is global, reusable master data; a POI is never duplicated because several properties recommend it.
  • mdm.POIProperty is the many-to-many curation: recommended, featured, visibility, ordering, travel and commercial settings.
  • Hierarchical classification: POICategory (with parent) and POIType.
  • Route Planner in dbo references POIs but snapshots name, address and coordinates on each stop.
  • The first stop is the property (PROPERTY_ORIGIN) without a duplicate POI; custom stops are allowed.
  • SQL Server GEOGRAPHY with a spatial index for proximity; routing results from an external engine persisted in RoutePlanLeg.
  • DistanceFromPropertyKM (proximity) and RoutePlanLeg.DistanceKM (journey) stay separate measures.
  • Location tracking only with explicit guest consent and a retention policy.

Next iteration

  • Google Routes / HERE / Mapbox RoutingProvider for traffic-aware legs and geometry (the estimate stays the offline fallback).
  • POI ingestion job: provider feeds into PENDING records, de-duplicated on POIExternalReference and the 75 m rule, verified in the console.
  • Recommendation ranking per guest (tags, stay context, time of day) feeding DisplaySequence or a separate score.
  • Links to bookable experiences, restaurant reservations, spa and transport requests from a stop (the v2 "request services" step).
  • Engagement events (impression, open, add to plan, visit) into the analytics store for recommendation conversion.

Refinements

Each reference appears as a comment in the SQL script.

RefAreav2 as writtenRefinementWhy
R1Association historyUNIQUE (PropertyGUID, POIGUID) together with EffectiveFrom/To and RecordStatusFiltered unique index: one ACTIVE association per property and POI. Ending sets ENDED and keeps the row; re-linking adds a new rowThe plain unique key made "one current association" impossible to combine with history
R2Spatial columnGeoLocation GEOGRAPHY NULL, populated separatelyNOT NULL, set from Latitude/Longitude (SRID 4326) inside usp_POI_Upsert onlyProximity search can never miss a POI or use stale coordinates
R2bSame-route integrityLeg stops and stop events "validated by the application"Composite foreign keys (RoutePlanGUID, StopGUID) on legs and events; events also prove their execution belongs to the routeThe database enforces it; no application can store a leg between two routes
R3Type within categoryNoted as an application validationComposite FK (POITypeGUID, POICategoryGUID) to a unique key on POITypeA museum type cannot sit under Dining, whatever writes the row
R4Opening hoursPOIOperatingHours listed ("by day and seasonal period") with no DDLSeasonCode + ValidFrom/ValidTo + DayOfWeek + SessionNo, plus POIHoursException; fn_POI_IsOpenAt resolves the seasonSplit sessions (Friday prayer break), late-night sessions, Ramadan and public holidays
R5Distance upkeepDistanceFromPropertyKM "calculated", no mechanismCalculated by the procedures on link, on POI move and by usp_POIProperty_RefreshDistances; DistanceCalculatedAt recordedThe guest feed reads a stored value and it never goes stale silently
R6Status and code valuesFree-text NVARCHAR(30) columnsCHECK constraints with upper-case codes for every status, type, mode and event; "public transport" = TRANSITWeb, API and Flutter share one vocabulary; bad values are rejected at source
R6bStop type rulePOIGUID nullable for custom stopsCHECK: POI stops must have a POIGUID; origin, custom and final stops must not; one origin per routeNo half-formed stops
R7RatingsAverageRating on the POImdm.POIProviderRating, one row per provider with count and retrieval timeProvider terms differ and mixed averages mislead guests
R8Provenance and de-duplicationListed as a next stepSource, LastVerifiedAt, POIExternalReference unique on (Provider, ExternalId); upsert refuses the same name within 75 m (50005)Ingestion from several feeds without duplicates; for Google keep the place_id only
R9Missing DDLPOIContact, POIMedia, POIFacility named onlyTables created; mdm.Facility reference list behind POIFacility; media keeps an attribution lineComplete physical model
R10TenancyNot addressedOwnerTenantGUID on POI (NULL = global AGRAAJA POI); TenantGUID copied to RoutePlan; every procedure takes @TenantGUIDIsolation enforced in the data layer as well as the API
R11Business numbersPOICode and RoutePlanNumber required, no generatorSequences mdm.POISequence and dbo.RoutePlanNumberSequence (POI-1021, RP-2026-000042)Readable references for staff and guests
R12ConcurrencyNoneInteger Version on POI, POIProperty and RoutePlan; procedures refuse stale writes (50009, HTTP 409)Two curators cannot overwrite each other silently
R13Guest renderingNot specifiedColorHex and IconKey on POICategoryConsole, Guest web and Flutter look the same
R14Planner inputsNot specifiedShortDescription, Locality, TypicalVisitMinutes on POI; DefaultVisitMinutes on POITypeCards and itineraries without extra calls
R15LanguagesSingle languagemdm.POITranslation (Arabic, English, guest languages) with fallbackGuests see their language
R16Association groupingIsRecommended / IsFeatured onlyAssociationType NEARBY, RECOMMENDED, PARTNER, AFFILIATED, ESSENTIAL (flags kept)Guest App sections (Essentials) and partner reporting
R17Return to propertyFINAL_DESTINATION type onlyReturnToOrigin on RoutePlan; the save procedure adds PROPERTY_ORIGIN and FINAL_DESTINATION from core.PropertyClients send visits only; origin and return are always correct
R18RecalculationLastCalculatedAt on legsRoutingProvider, CalculationVersion and LastCalculatedAt on the headerKnow which engine and run produced the timings
R19Leg geometry for appsRouteGeometry GEOGRAPHYKept, plus EncodedPolyline and JSON-checked RouteInstructionsFlutter maps draw a polyline without spatial conversion
R20Live executionSeveral executions possible at onceFiltered unique index: one STARTED or PAUSED execution per route; CurrentStopSequenceOne truth for "where is the guest in the trip"
R21Consent and retentionStated as a principleLocationConsentGiven/At; CHECK forbids a stored position without consent; usp_RouteExecution_PurgeLocations clears positions after N daysThe principle is enforced by the schema and a scheduled job
R22City & Country Master TablesFree-text City and CountryCode on POImdm.Country and mdm.City master tables with ISO codes, states/emirates, foreign keys, and cascading UI dropdownsStandardised master data eliminates spelling variations and enables structured multi-city filtering and curation