Data Ownership
Each piece of live data has exactly one owner that writes it. Other parts ask the owner, or keep a read-only copy fed by events; they never read or write its tables. Report data is a different problem: a central warehouse, a raw lake, or a data mesh where each domain publishes its data as a product.
Author: bezzad
Contents
The problem: everybody wants everybody’s data
Our online shop is split into modules: Catalog, Order, Payment, Inventory, Shipping. Each one has its own tables. Soon the questions start:
- The Order module needs the product name and price. They live in Catalog.
- The Warehouse app wants to update the stock count. Inventory also updates it.
- The finance team wants a monthly report that joins orders, payments and products.
Each question has an easy answer: “just read the other tables”. That easy answer slowly turns the system into one big tangle. This lesson shows better answers.
Two kinds of data
- Operational data. The live state the shop runs on: carts, orders, stock. It must be correct now. Many small reads and writes.
- Analytical data. History used to answer questions: “Which products sell best in winter?”. It can be minutes or hours old. Few, very large reads.
They have different needs, so we solve them in different ways.
Rule 1: each piece of data has one owner
The owner is the only part that writes that data, and it keeps the business rules for it. Others never touch its tables.
Why?
- Rules live in one place. “Stock can never go below zero” is checked by Inventory only.
- The owner can change its tables freely. Nobody outside depends on them.
- There is one truth. When two parts write the same row, it is unclear who is right.
What if two parts need to change the same data? Pick one owner. The other part asks the owner: “reserve 2 items”, “50 items arrived”. If a table holds data of two owners, it is often two things in one table. Split it.
Rule 2: others read through the owner
When Order needs product prices, there are three ways:
| Way | Fresh? | Works if owner is down? | Coupling | Good when |
|---|---|---|---|---|
| 1. Ask the owner (API) | Always | No | Contract | You need the exact value now, like the final price at payment |
| 2. Local copy fed by events | A few seconds old | Yes | Contract (the events) | You read often and small delays are fine, like product names in order history |
| 3. Read its tables | Always | Depends | Intrusive | Almost never; maybe a short first step when splitting an old monolith |
A few notes on the local copy:
- The copy is read-only. Only the owner changes the real data.
- Keep only the fields you need. An order needs the product name and price, not the full product.
- Save the price inside the order at the moment of buying. Later price changes must not change old orders. This is not only a copy, it is a business fact.
Who owns what? Use the business
Draw ownership from the business, not from the database schema:
- The thing that creates the data and checks its rules is usually the owner.
- “Product” can mean different things: name and photos (Catalog), count on the shelf (Inventory), weight and size (Shipping). Each module owns its own part. This is the idea of the bounded context in DDD.
Analytical data: the report problem
Finance wants one report from five modules. Running big queries on each live database is a bad idea: it slows down checkout, and it couples the report to private tables.
So we copy data into a separate place made for reports. There are three main shapes:
- Data warehouse. A central data team pulls data from all modules (ETL: extract, transform, load) into one clean model. Great for standard reports. But the central team becomes a bottleneck, and it must understand every domain.
- Data lake. Dump the raw data cheaply, and clean it later for each use (reports, machine learning). Flexible. But without owners and rules, it becomes a “data swamp” that nobody trusts.
- Data mesh. Each domain team publishes its analytical data as a data product, with a shared self-service platform and a few common rules for everyone. The people who know the data are responsible for it.
A good data product is like a good API:
- Easy to find (in a catalog) and easy to understand (documented meaning of each field).
- Trustworthy: it states how fresh it is and checks its own quality.
- Has a contract: its schema changes carefully, like any public API.
Many companies use a mix: domain-owned data products, plus a small central layer for company-wide numbers, plus a lake for raw data and machine learning.
Common mistakes
| Mistake | Result | The right way |
|---|---|---|
| Two modules write the same table | Broken rules and unclear truth. | One owner; others send requests. |
| Reading another module’s tables | Their change breaks you. | Ask the owner, or keep a copy fed by events. |
| Copying the full object “just in case” | Strong model coupling. | Copy only the fields you use. |
| Heavy reports on the live database | Slow checkout at the worst time. | A separate analytical store. |
| A data lake with no owners | A swamp of data nobody trusts. | Owners, contracts and quality checks. |
Summary in six lines
- Operational data runs the system now; analytical data answers questions later.
- Each piece of live data has exactly one owner that writes it and keeps its rules.
- Others ask the owner, or keep a small read-only copy fed by events.
- Reading another module’s tables is intrusive coupling; avoid it.
- Report data lives in a separate store: warehouse, lake, mesh, or a mix.
- In a data mesh, domains publish data products with owners, contracts and quality checks.