Data ownership: one owner per piece of data, database per service vs schema per module, no shared writes, reporting via read models or a warehouse, and synchronising copies with events and the outbox.
Data ownership means each piece of data has one owner, a module or service, that is the only one allowed to write it and enforce its invariants. Everyone else either asks the owner (API), subscribes to its events, or keeps a read-only local copy.
In microservices that usually means database per service; in a modular monolith it means schema per module with its own DbContext, and no cross-module joins.
Shared writes are the thing to avoid: two services updating the same table means nobody owns the rules and every schema change is a coordinated release. For reporting, I ship data to a separate analytical store instead of joining live databases.
The trade-off is duplication and eventual consistency: copies lag the owner, so you design for staleness and synchronise with an outbox.
"Data ownership is the rule that every piece of data has exactly one owner that writes it and protects its invariants. In a microservices system that's a database per service, or at least a schema per service with no other service granted access. Inside a modular monolith I do the same thing with a schema per module and a separate DbContext, so the Orders module can't accidentally join into the Customers tables. Other parts of the system get data in one of three ways: call the owner's API, subscribe to its events, or keep a local read-only copy built from those events.
For example, at [company] we had [four] services all writing to a shared
Customertable in one Azure SQL database. Billing changed the email format, Marketing had a trigger that assumed the old one, and a release broke [newsletter sign-ups] for [two] days. Nobody knew who owned the rules. I proposed making the Customer service the sole writer, exposing aCustomerChangedevent with the fields others actually needed, and giving Billing and Marketing their own projections. We moved writes over one consumer at a time, and schema changes in Customer went from needing [four] team sign-offs to one.The mistake I see is treating 'database per service' as the goal and then rebuilding joins with chatty synchronous calls, or the opposite, keeping one shared database 'for reporting' and letting writes leak back in. My senior line is: share data by contract, never by table, and decide up front which copies are allowed to be stale and by how much."
| Approach | How | Consistency | When it fits | Cost |
|---|---|---|---|---|
| Query the owner's API | HTTP/gRPC call | Fresh | Low volume, need current data | Runtime coupling, latency |
| Event-carried state transfer | Owner publishes events with needed fields; consumer stores a copy | Eventual | High read volume, tolerates lag | Storage, sync logic, versioning |
| Shared database, separate schemas, read-only views | Owner exposes a view; others read only | Fresh | Transitional step inside a monolith | Schema coupling; discipline needed |
| Shared tables, shared writes | Everyone writes | β | Never as a target state | Broken invariants, coordinated releases |
| Schema per module | Database per service | |
|---|---|---|
| Isolation | Logical (permissions, separate DbContexts) | Physical |
| Cross-module transaction | Technically possible (avoid it) | Not possible without sagas |
| Ops cost | One database | One per service; backups, scaling, cost |
| Fits | Modular monolith | Independently deployed services |
| Need | Approach |
|---|---|
| Operational dashboards on one service | That service's read model or a read replica |
| Cross-domain analytics | CDC or events into Microsoft Fabric / a warehouse |
| Near-real-time cross-domain view | Dedicated projection service fed by events |
Making Customer the single writer and moving [three] consumers to event-fed projections removed the coordinated schema releases, cut customer-related incidents from [six] a quarter to [one], and kept projection lag under [5 seconds] at p99.
Checks whether the candidate understands single-writer ownership, how to share data without coupling, and the consistency, reporting and privacy consequences.
Green flags
Red flags
An invariant ("a customer's email is unique and verified before marketing can use it") can only be enforced where the data is written. If three services write the same rows, each needs a copy of the rule, and they drift.
Shared writes (bad) Single owner (good)
βββββββββββ βββββββββββ βββββββββββ ββββββββββββ CustomerChanged βββββββββββ
β Billing β βMarketingβ β Support β β Customer β βββββββββββββββββΊ β Billing β (copy)
ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ β service β βββββββββββββββββΊ βMarketingβ (copy)
βββββββββββββΌββββββββββββ β writes β βββ API calls βββββ β Support β
βΌ ββββββ¬ββββββ βββββββββββ
dbo.Customer βΌ
customer DB
HasDefaultSchema("customers"), internal entity types, and migrations per context.GRANT ... ON SCHEMA::customers).DbContext or entity types.The dual-write problem: writing to your database and publishing to a broker are two operations; either can fail. The transactional outbox writes the event to an outbox table in the same transaction as the change; a relay publishes it later.
Consumers must be:
OrderPlaced before it has the CustomerCreated copy; design a fallback (call the owner, park and retry).Copy only what the consumer needs, ideally in its own language (Billing stores BillingContact, not the whole Customer). Copying everything recreates coupling to the owner's schema and spreads personal data, which increases your Privacy Act and NDB surface.
Operational databases are tuned for the owner's writes and reads. Cross-domain reporting joins should happen in an analytical store:
service DBs ββCDC / eventsβββΊ landing zone βββΊ warehouse / Fabric lakehouse βββΊ Power BI
Azure SQL change tracking/CDC or event streams feed it. Reporting latency of minutes is usually acceptable, and the services stay free to change their schemas as long as the published feed is versioned.
Under the APPs, people can request access to and correction of their personal information, and an eligible data breach must be assessed and notified. If you know which service owns each personal field and which copies exist, these become tractable. A map of owners and copies is a privacy control, not just an architecture diagram.
BackgroundService.A consumer keeping a minimal, version-aware local copy of data owned by another service.
namespace Billing.Infrastructure;
using Microsoft.EntityFrameworkCore;
// Published by the Customer service (the owner). Carries only what consumers need plus a version.
public sealed record CustomerChanged(Guid CustomerId, string BillingEmail, string LegalName, long Version);
// Billing's own, minimal copy in its own schema and language.
public sealed class BillingContact
{
public Guid CustomerId { get; init; }
public string Email { get; set; } = "";
public string LegalName { get; set; } = "";
public long SourceVersion { get; set; }
}
public sealed class BillingDbContext(DbContextOptions<BillingDbContext> options) : DbContext(options)
{
public DbSet<BillingContact> Contacts => Set<BillingContact>();
protected override void OnModelCreating(ModelBuilder b)
{
b.HasDefaultSchema("billing");
b.Entity<BillingContact>().HasKey(c => c.CustomerId);
}
}
public sealed class CustomerChangedHandler(BillingDbContext db)
{
public async Task HandleAsync(CustomerChanged e, CancellationToken ct)
{
var contact = await db.Contacts.FindAsync([e.CustomerId], ct);
if (contact is null)
{
db.Contacts.Add(new BillingContact
{
CustomerId = e.CustomerId, Email = e.BillingEmail, LegalName = e.LegalName, SourceVersion = e.Version
});
}
else if (e.Version > contact.SourceVersion) // ignore stale or duplicate deliveries
{
contact.Email = e.BillingEmail;
contact.LegalName = e.LegalName;
contact.SourceVersion = e.Version;
}
await db.SaveChangesAsync(ct);
}
}
-- Each service's managed identity can only touch its own schema.
CREATE USER [billing-api] FROM EXTERNAL PROVIDER;
GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::billing TO [billing-api];
SaveChanges without an outbox. Why it is wrong: A crash between the two loses the event and copies silently drift. Instead: Use a transactional outbox and an idempotent relay.Ownership is mostly a governance decision with a technical enforcement. I make the owner explicit in the architecture docs (a data ownership table per context), enforce it with per-identity database permissions and architecture tests, and keep traceability by having the owner record who changed what (audit columns or temporal tables) and by propagating trace ids into events.
I also define a staleness budget for every copy ("Billing's contact copy may lag up to 1 minute"). If the budget is seconds-to-minutes, an event-fed copy is right. A synchronous call to the owner is justified when the decision must use the current value and a wrong answer is costly, for example checking available credit before approving a payment, and the call volume is modest. If many hot-path operations in one service need another service's data to be exactly current, that usually means the two belong in the same boundary.
Operationally, database per service means separate backups, HA configuration, scaling and cost for each database; an Azure SQL elastic pool can soften the cost. In a modular monolith I start with schema per module in one database: cheap, clear ownership, and later extraction becomes a data move rather than a redesign.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Schema per module, one DB | Modular monolith, one deployable | Low | Modules deployed independently |
| Database per service | Independent services and teams | Higher ops and consistency cost | Small team, one deployable |
| Event-fed local copy | High read volume, lag acceptable | Sync and versioning logic | Strong consistency required |
| Synchronous API lookup | Low volume, must be fresh | Runtime coupling | Hot paths, long call chains |
An integration event is a public API owned by the publisher. Within a version I only make backward-compatible changes: add optional (nullable or defaulted) fields. I never add a required field mid-version (messages already in queues won't have it), and never rename, remove or retype. Consumers are tolerant readers: they ignore unknown fields and default missing optional ones. A breaking change becomes a new event type (orders.order-placed.v2), published alongside v1 until consumers move, then deprecated with a date.
I wrap events in a CloudEvents envelope (id, source, type, time, dataschema). Each publisher ships its own contracts package or JSON Schema; one shared events library for every service forces lockstep upgrades.
The trade-off: discipline and some duplication in exchange for independent deployments.
I'd first confirm the mechanics: Azure Service Bus delivers at least once and only orders messages within a session, so after a release that raised consumer concurrency or scaled out, events for the same order can be processed out of order and redelivered. Traces with event ids, aggregate versions and delivery counts prove it.
The fixes: every event carries the aggregate version and the consumer applies it only if newer (or I use sessions keyed by order id); an inbox with a unique key dedups by message id in the same transaction; increments like loyalty credits use a natural idempotency key (order id plus reason). Unknown event versions dead-letter. Then I rebuild the corrupted state from the source of truth.
The trade-off: sessions give ordering but limit parallelism per key; version checks keep parallelism but require versioned events.
A modular monolith is one deployable split into modules aligned to business capabilities β Orders, Billing, Catalogue β each with hard boundaries.
DbContext, no cross-module joins or foreign keys.internal.internal types, architecture tests, even per-schema database permissions.You get microservice-style boundaries with monolith-style operations: one pipeline, in-process calls, easy refactoring. The trade-off: one runtime, one release and one scaling unit, and it only works if the boundaries are enforced β otherwise it decays into a big ball of mud.
How to tell it (STAR)
**S:** At [company] four services wrote the same Customer table, and a Billing change broke Marketing sign-ups for [two] days. **T:** As the senior engineer on Customer, I had to stop these cross-team breakages. **A:** I showed who wrote what using Query Store and audit logs, wrote an ADR making Customer the only writer, and introduced a `CustomerChanged` event through an outbox. I moved Billing and Marketing to small local copies one at a time, then revoked their write permissions. **R:** Customer schema changes went from [four] team sign-offs to one, customer-data incidents dropped from [six] to [one] a quarter, and projection lag stayed under [5 seconds] at p99.
Last updated 23 Nov 2026.