Skip to main content

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 keyEntityIndex
CompatIdAssetUX_Assets_CompatId
EventIdOutboxMessageIX_OutboxMessages_EventId
EventIdProcessedIntegrationEventUX_ProcessedEvents_EventId

Enforced relationships (2, both cascade, both required)​

#PrincipalDependentCardinalityForeign keyDelete behaviorNavigationSource
1Assets (Id)AssetAssignmentHistoryone-to-manyAssetId (required)CascadeAsset.History → WithOneAssetDbContext / Asset.cs
2Assets (Id)AssetDocumentReferencesone-to-manyAssetId (required)CascadeAsset.Documents → WithOneAssetDbContext / 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:

ReferenceHeld onPoints at
AssignedToUserIdAsset (owned AssetAssignee)platform/identity user
LaborIdAsset (owned AssetAssignee); also on historylegacy employee (labor) record
WorkflowInstanceIdAssetWorkflow Service instance
DocumentServiceIdAssetDocumentReferenceDocument Service document id
StorageObjectIdAssetDocumentReferenceDocument Service physical blob id
CompatIdAssetmonolith asset-record id (compatibility)
UserIdAssetAssignmentHistoryplatform/identity user
EntityId (string)AssetAuditLog, AssetTimelinethe 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​

See Also​

Keywords​

  • Asset keys
  • Keys and Relationships
  • Keys relationships

Source References​

  • microservices/src/asset-service/Infrastructure/AssetDbContext.cs
  • microservices/src/asset-service/Domain/Asset/Asset.cs
  • microservices/src/asset-service/Infrastructure/Migrations/AssetDbContextModelSnapshot.cs
  • microservices/src/asset-service/Infrastructure/Migrations/20260707123634_InitialAssetSchema.cs

Revision Information​

  • Status: Draft
  • Last reviewed: 2026-07-17
  • Review cycle: Quarterly