Asset Keys and Relationships
Summary
Source-backed inventory of keys and relationships in the Asset bounded context: seven Guid primary keys, three unique keys, two enforced cascading foreign-key relationships, and a set of identifier-only cross-service references that are not database relationships.
Audience
Backend engineers, database reviewers, architects, QA, support, operations, security reviewers, and product owners.
Overview
The only database-enforced relationships are the two aggregate-child links from history and document references back to the Asset aggregate. Every reference to a user, labor record, workflow instance, document-service object, or the monolith compatibility id is a plain identifier value with no foreign key — these span service boundaries and are intentionally not modeled as relationships.
Confirmed persistence behavior
Primary keys (7, all Guid)
Assets, AssetAssignmentHistory, AssetDocumentReferences, AssetAuditLogs, AssetTimeline, ProcessedIntegrationEvents, OutboxMessages.
Alternate / unique keys (3)
| Unique key | Entity | Index |
|---|---|---|
CompatId | Asset | UX_Assets_CompatId |
EventId | OutboxMessage | IX_OutboxMessages_EventId |
EventId | ProcessedIntegrationEvent | UX_ProcessedEvents_EventId |
Enforced relationships (2, both cascade, both required)
| # | Principal | Dependent | Cardinality | Foreign key | Delete behavior | Navigation | Source |
|---|---|---|---|---|---|---|---|
| 1 | Assets (Id) | AssetAssignmentHistory | one-to-many | AssetId (required) | Cascade | Asset.History → WithOne | AssetDbContext / Asset.cs |
| 2 | Assets (Id) | AssetDocumentReferences | one-to-many | AssetId (required) | Cascade | Asset.Documents → WithOne | AssetDbContext / Asset.cs |
Identifier-only references (NOT database relationships)
These are scalar values that point at data owned by other services or the monolith. They have no foreign key, no navigation, and no referential enforcement:
| Reference | Held on | Points at |
|---|---|---|
AssignedToUserId | Asset (owned AssetAssignee) | platform/identity user |
LaborId | Asset (owned AssetAssignee); also on history | legacy employee (labor) record |
WorkflowInstanceId | Asset | Workflow Service instance |
DocumentServiceId | AssetDocumentReference | Document Service document id |
StorageObjectId | AssetDocumentReference | Document Service physical blob id |
CompatId | Asset | monolith asset-record id (compatibility) |
UserId | AssetAssignmentHistory | platform/identity user |
EntityId (string) | AssetAuditLog, AssetTimeline | the asset id, as a free-form string (not a FK) |
Totals
- Primary keys: 7 (all Guid)
- Alternate / unique keys: 3 (
CompatId,OutboxMessages.EventId,ProcessedIntegrationEvents.EventId) - Enforced relationships: 2
- Cascading: 2; restrictive: 0; optional: 0
- Identifier-only references: multiple (listed above), none of which is a database relationship
Classification
Implemented aggregate-internal referential integrity with Transitional, intentionally decoupled cross-service references.
Requires confirmation
Whether any cross-service identifier reference should gain referential validation (for example a lookup/verification step) beyond the current identifier-only model requires confirmation.
Diagram
Related Articles
See Also
Keywords
- Asset keys
- Keys and Relationships
- Keys relationships
Source References
microservices/src/asset-service/Infrastructure/AssetDbContext.csmicroservices/src/asset-service/Domain/Asset/Asset.csmicroservices/src/asset-service/Infrastructure/Migrations/AssetDbContextModelSnapshot.csmicroservices/src/asset-service/Infrastructure/Migrations/20260707123634_InitialAssetSchema.cs
Revision Information
- Status: Draft
- Last reviewed: 2026-07-17
- Review cycle: Quarterly