Skip to main content

Expense Indexing and Query Patterns

Summary

The EF model defines primary, unique, relationship-supporting, tenant, workflow, and relay indexes. The catalog below lists their mapped properties without exposing physical database identifiers.

Audience

Backend developers, database reviewers, QA, architects, DevOps, support, and implementation teams.

Confirmed persistence

Persisted objectPropertiesKindConfirmed query use
ExpenseClaimIdPrimary keyAggregate lookup
ExpenseClaimCompatIdUnique secondary indexCompatibility lookup and backfill identity
ExpenseClaimTenantId, StatusSecondary composite indexTenant-scoped status listing
ExpenseClaimWorkflowInstanceIdSecondary indexWorkflow correlation
ExpenseReceiptReferenceIdPrimary keyReceipt-reference identity
ExpenseReceiptReferenceExpenseClaimIdRelationship-supporting indexClaim-to-receipt relationship
ExpenseReceiptReferenceTenantId, ExpenseClaimIdSecondary composite indexTenant-scoped claim receipt lookup
ExpenseAuditLogIdPrimary keyEvidence identity
ExpenseAuditLogTenantId, OccurredAtUtcSecondary composite indexTenant-scoped recent evidence
ExpenseTimelineIdPrimary keyTimeline identity
ExpenseTimelineTenantId, OccurredAtUtcSecondary composite indexTenant-scoped recent activity
OutboxMessageIdPrimary keyMessage identity and relay update
OutboxMessageEventIdUnique secondary indexDuplicate event prevention
OutboxMessageStatus, OccurredAtUtcSecondary composite indexOldest-first Pending/Failed relay scan
ProcessedIntegrationEventIdPrimary keyLedger-record identity
ProcessedIntegrationEventEventIdUnique secondary indexConsumer idempotency

Claims list by optional status or employee reference, recent-first with a fixed cap. Detail reads load receipt children. Relay reads select Pending or Failed records oldest-first. Evidence reads are recent-first and no-tracking.

No employee/date composite index, general pagination, full-text search, cache, partitioning, or performance target is confirmed.

Requires confirmation

Production migration governance, retention, archival, masking, performance targets, concurrency roadmap, operational-store access, and rollback ownership remain unconfirmed unless narrowed above.

Source References

  • microservices/src/expense-service/Infrastructure/ExpenseDbContext.cs
  • microservices/src/expense-service/Application/Queries/ExpenseQueries.cs
  • microservices/src/expense-service/Infrastructure/Persistence.cs

See Also

Keywords

  • Expense database
  • Indexing and Query Patterns

Revision Information

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