Core Idea

The Data Domain Pattern allows multiple services to share database ownership of common schema elements (tables, schemas) within a bounded context while maintaining joint responsibility for data integrity and evolution. It trades implementation simplicity for managed coupling.

Definition

The Data Domain Pattern is a data management approach where multiple related services share access to common database schema elements (tables, schemas) within the same bounded context. Unlike strict “database per service” isolation, this pattern recognizes that services with high semantic cohesion may benefit from shared data structures when properly governed. It trades implementation simplicity and ACID transaction support for managed coupling between services.

Key Characteristics

  • Shared schema ownership: Multiple services jointly own tables or schemas within a bounded context, requiring coordinated schema evolution but enabling simpler data access
  • Bounded context alignment: Services sharing data belong to same domain boundary where terms have unified meanings—sharing across bounded contexts is discouraged
  • Development-time coupling: Schema changes require coordination among services, creating team dependencies and potentially slowing independent evolution
  • Runtime coupling potential: Long-running transactions can block other services accessing shared tables, degrading system responsiveness
  • ACID transaction simplification: Transactions spanning entities remain local and atomic, avoiding distributed transaction complexity (sagas, two-phase commit)
  • Incremental migration enabler: Used as intermediate step when decomposing monoliths—logically partition tables while planning eventual physical separation

Examples in Practice

  • E-commerce bounded context: Catalog, Pricing, and Inventory services share Product tables—tight semantic coupling and consistency requirements justify shared schema
  • Banking account management: Account Details, Transaction History, and Balance services access shared Account tables within single domain context
  • Monolith decomposition: Extract Order Processing service while connected to shared database with Fulfillment—schema separation planned for later phase

Why It Matters

The Data Domain Pattern represents pragmatic architecture acknowledging not all distributed problems need identical solutions:

  • Simplicity over purity: Avoids complex distributed data patterns when services genuinely share semantic domain, reducing operational complexity
  • Incremental migration: Enables gradual monolith decomposition without immediately solving every data isolation challenge
  • Transaction consistency: Provides ACID guarantees that are architecturally complex in fully distributed systems
  • Bounded context enforcement: Restricts sharing within contexts, preventing enterprise-wide shared database anti-pattern while allowing legitimate domain sharing
  • Performance: Eliminates network latency and serialization overhead of inter-service calls for data access

Sources

Note

This content was drafted with assistance from AI tools for research, organization, and initial content generation. All final content has been reviewed, fact-checked, and edited by the author to ensure accuracy and alignment with the author’s intentions and perspective.