Scrivio Interview library
LeadershipPrincipal7 min read · updated 12 November 2026

Your company's entity model is shared as a library by 15 services that all read and write the same database. Over the years, every schema change needs all teams. What would you change, and over what timeframe?

A shared entity library over a shared database couples every team to every schema change, so I would move to data ownership: each table gets one owning service, and other services reach that data through APIs or events. We stop adding to the shared library and give new features their own schema, then move existing tables one domain at a time, using views or replication during each transition. This is a multi-year effort, so we track progress with a simple measure: the number of schema changes that still need more than one team.

Why this question is asked

Sharing one entity library across many services starts as a sensible way to avoid duplication. Years later it is often the main reason the organisation is slow: every column change needs a new library version, fifteen teams must upgrade, and nobody can deploy alone. Interviewers ask this at principal level because the fix is not a technique but a long programme, and the answer shows whether we can sequence it, keep the business running and measure progress. In this answer, we will look at why the coupling happens, set the target of one owner per table, stop the problem growing, move existing domains step by step with transition tools, and set a realistic timeframe with a measure that tells us we are winning.

1Why the Shared Library Couples Everyone

An entity class is a description of a table: its columns, types and relationships. When fifteen services share the same classes, they all depend on the same description. Renaming a column means changing the entity, releasing the library, and upgrading every service before the old column can go, because any service still on the old version would fail against the new schema. The database itself adds a second coupling: even a service that upgraded the library can break another service's query by adding a constraint or changing data meaning.

So the real problem is not the library, it is shared ownership of the data. Nobody owns the orders table; everybody does. Every change becomes a negotiation, and the safest decision for each team is to avoid changing anything, which slowly freezes the schema.

2The Target: One Owning Service per Table

The goal is that every table has exactly one owning service. Only the owner reads and writes it directly and defines its entities. Other services that need the data ask the owner, through an API for queries and commands, or by consuming events the owner publishes when the data changes, and keep their own copy if they need fast local reads.

With ownership, a schema change is a decision inside one team. The owner can rename a column, split a table or change a type, as long as its API and events keep their contract. Contracts are much easier to version than shared tables, because they can support old and new versions side by side for a while.

Before and after ownership
QuestionShared library and databaseOwned data
Who can change the orders table?Anyone, with everyone's agreementThe orders service alone
How do others read orders?Direct SQL through shared entitiesOrders API or order events
What a column rename needsLibrary release, 15 upgrades, coordinated deployOne team's migration; contract unchanged
Deploy independenceLowHigh

3Step One: Stop the Problem Growing

Before moving anything, we stop adding to it. New features no longer get tables in the shared database or classes in the shared library; they get their own schema owned by the service that builds them. The shared library is frozen for additions, and changes to existing entities need a short review that asks whether the change could go into an owned schema instead.

This step is cheap and has an immediate effect. Without it, the migration would be chasing a target that keeps growing, because every new feature would add more shared tables than we could move.

4Step Two: Move Existing Tables One Domain at a Time

Next we pick one domain, for example product catalogue, and give it an owner. We list every service that reads or writes its tables, which a database audit or query logs can show, and choose the order to move them. A domain with few writers and clear boundaries goes first, to prove the approach.

The transition uses tools that let old and new readers coexist. A database view can present the old shape of a table while the owner changes the real one underneath, so consumers that still read directly keep working. Replication or change data capture, such as Debezium reading the database log, can copy the owner's data into a read-only copy for consumers until they switch to the API or events. Consumers then migrate one by one, and when none read the tables directly, we remove their access and the entities from the shared library.

SQL
-- Transition: consumers still read the old shape through a view
CREATE VIEW legacy.product AS
SELECT id, sku, display_name AS name, price_cents / 100.0 AS price
FROM catalog.product; -- the owner has already renamed and changed columns
REVOKE INSERT, UPDATE, DELETE ON legacy.product FROM reporting_app; -- reads only during the move
Step throughMoving one domain
  1. Name the owning team and service
  2. List every reader and writerquery logs, database audit
  3. Owner publishes an API and change events
  4. Old readers use a view or a replicated copy
  5. Consumers switch one by one
  6. Any direct access left?
    YesKeep the view, follow upNoRevoke access, delete shared entities

6 steps in order. Play them, or step through them one at a time.

5A Realistic Timeframe

For fifteen services and a database that has grown for years, this is a multi-year effort, typically two to four years, and saying so at the start is part of the job. In the first quarter we freeze the shared library and name owners for every table. Over the first year we move two or three domains, the easiest first, and learn what slows us down. In the following years we move the remaining domains, with the hardest, most shared tables, often customers and orders, last, when the team has experience and tooling.

The business does not stop during this time, so the work runs alongside features, and each domain move should deliver a visible benefit, such as that team deploying independently, to keep support.

6Measuring Progress

A long programme needs a number that shows whether it is working. The best one measures the pain directly: the number of schema changes per quarter that needed more than one team to coordinate. We get it from migration pull requests and the shared library's release notes. At the start it may be most changes; as domains move, it should fall steadily. Two supporting measures help: the share of tables with a single owner and no direct outside access, and the number of services that still depend on the shared library.

Text
Quarter cross-team schema changes tables owned exclusively services on shared library
Q1 34 of 40 5 percent 15
Q4 21 of 38 30 percent 11
Q8 6 of 35 70 percent 4 // the trend is the goal

7Follow-up questions

Why not just split the database first and sort out ownership later?

Because splitting without ownership moves the coupling instead of removing it. If two services still write the same table, putting it in a separate database only adds distributed transactions to the problem. Ownership decides where each table goes; the physical split follows.

What do you do with data that many services genuinely need, such as customers?

The owner provides a good read API and publishes change events, and consumers keep a local copy of the fields they need, updated from the events. That is more work than a join, but each consumer then controls its own read model and the owner can change its schema freely. Such domains usually go last, once the event infrastructure is proven.

How do you keep teams motivated through a multi-year effort?

By making each step pay off on its own. Every moved domain should give its owning team faster, independent deploys, and that story should be shared. A visible dashboard with the cross-team change count also shows the whole organisation that the work is reducing a pain everyone feels.

8Conclusion

In this answer, we saw that a shared entity library on a shared database couples every team to every schema change, because nobody owns the data. The fix is to give each table one owning service and have others use APIs or events. We freeze the shared library and give new features their own schemas, move existing domains one at a time using views and replication during transitions, plan for a multi-year programme with the hardest domains last, and track the number of cross-team schema changes as the measure of progress.

What to say in the interviewAbout 90 seconds aloud

Open with

The root problem is not the library, it is that nobody owns the data. With fifteen services reading and writing the same tables through shared entities, every column change needs a library release and coordinated upgrades, so the safest choice is never to change anything.

Then, if they want more

I would set the target that every table has exactly one owning service; others use the owner's API for queries and commands, or its events if they need a local copy. First, I would stop the problem growing: freeze the shared library for additions and give every new feature its own schema.

Then I would move existing tables one domain at a time, starting with one that has few writers to prove the approach.

For each domain, the owner publishes an API and change events, remaining direct readers use a view that keeps the old shape or a replicated read-only copy, consumers switch one by one, and when nobody reads directly we revoke access and delete the entities from the shared library.

I would be honest that this takes two to four years, with shared domains like customers and orders last. To show progress I would track the number of schema changes per quarter that need more than one team, plus the share of exclusively owned tables and services still on the library.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your company's entity model is shared as a library by 15 services that all read and...": https://scrivio-interview-library.netlify.app/databases/jpa-fundamentals/2d1d40a2ff/