From 272a25fb0527c9d23d261f3c2e7d58b297f083df Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Sat, 5 Sep 2026 00:44:59 -0400 Subject: [PATCH] docs(database): update City dbml doc to reflect composite unique constraint (#278) --- docs/web/database.md | 2 +- docs/web/diagrams/database-schema/geolocation.mmd | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/web/database.md b/docs/web/database.md index 8b962767..ab7068ee 100644 --- a/docs/web/database.md +++ b/docs/web/database.md @@ -80,7 +80,7 @@ updates (`UPDATE ... WHERE ... AND RowVersion = @RowVersion`). | `UserAvatar` | `Domain.Entities.UserAvatar`, `Features.Users` | Links a `UserProfile` to a `Photo` as its avatar; written via `IUserProfileRepository.SaveAvatarAsync` | | `BreweryPost` | `Domain.Entities.BreweryPost`, `Features.Breweries` | A user-submitted brewery listing | | `BreweryPostLocation` | `Domain.Entities.BreweryPostLocation`, `Features.Breweries` | 1:1 with `BreweryPost`; `Coordinates` is a `GEOGRAPHY` column, read via a plain Dapper query that selects `CONVERT(varbinary(max), Coordinates)`, since Dapper can't deserialize SQL Server UDTs directly | -| `City` | `Domain.Entities.City`, `Features.Locations` | Referenced by `BreweryPostLocation.CityID`; written via `ILocationRepository`, read via `ILocationRepository` and `IBreweryRepository`'s location joins, currently written only by `Database.Seed` | +| `City` | `Domain.Entities.City`, `Features.Locations` | Referenced by `BreweryPostLocation.CityID`; `CityName` and `StateProvinceID` together are unique; written via `ILocationRepository`, read via `ILocationRepository` and `IBreweryRepository`'s location joins, currently written only by `Database.Seed` | | `StateProvince` | `Domain.Entities.StateProvince`, `Features.Locations` | Referenced by `City.StateProvinceID`; created on demand by `ILocationRepository.GetOrCreateCityIdAsync`, read via `IBreweryRepository`'s location joins | | `Country` | `Domain.Entities.Country`, `Features.Locations` | Referenced by `StateProvince.CountryID`; created on demand by `ILocationRepository.GetOrCreateCityIdAsync`, read via `IBreweryRepository`'s location joins | | `Photo` | `Domain.Entities.Photo`, `Features.PhotoUpload` | Written via `IPhotoUploadRepository.CreateAsync`, sent as an `UploadPhotoCommand` from other features' handlers; not yet seeded by `Database.Seed` | diff --git a/docs/web/diagrams/database-schema/geolocation.mmd b/docs/web/diagrams/database-schema/geolocation.mmd index 241a6e40..f67aa781 100644 --- a/docs/web/diagrams/database-schema/geolocation.mmd +++ b/docs/web/diagrams/database-schema/geolocation.mmd @@ -18,8 +18,9 @@ erDiagram uniqueidentifier CountryID FK } + %% CityName + StateProvinceID form a composite unique constraint (AK_CityStateProvince) City { uniqueidentifier CityID PK - nvarchar CityName - uniqueidentifier StateProvinceID FK + nvarchar CityName UK + uniqueidentifier StateProvinceID FK,UK }