Quick revision
The short answer
The 60 nullable columns are several entities squeezed into one table, so first separate the concepts with the domain experts, typically User (a login identity), Organization (the customer company), BillingAccount (who pays) and Membership (a user in an organization with a role), and agree one word for each. Then introduce the new tables next to the old one, backfill, and move reads and writes over step by step in an expand and contract migration, deciding explicitly how to handle the edge cases the old model allowed.
What to remember
In this answer, we read the wide accounts table as several concepts mixed together, confirmed them with the business as User, Organization, BillingAccount and Membership, gave each its own table with real constraints, and migrated with expand and contract: new tables, backfill, dual writes with reconciliation, reads moved feature by feature, and the old columns dropped last. We also decided the edge cases explicitly and agreed one word per concept.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The 60 nullable columns are several entities squeezed into one table, so first separate the concepts with the domain experts, typically User (a login identity), Organization (the customer company), BillingAccount (who pays) and Membership (a user in an organization with a role), and agree one word for each. Then introduce the new tables next to the old one, backfill, and move reads and writes over step by step in an expand and contract migration, deciding explicitly how to handle the edge cases the old model allowed.
Why this question is asked
Overloaded words are one of the most expensive problems in software, because they hide in plain sight: everybody says account, and everybody means something slightly different. The schema then reflects the confusion, with one table trying to be everything. Interviewers ask this scenario to see whether we can untangle a model with the business rather than just refactor tables, and migrate without stopping the product. In this answer, we will read the symptoms in the wide table, separate the concepts with the business, design the new model, migrate with expand and contract, and handle edge cases and the vocabulary.
1Reading the Symptoms in a Wide Table
A table with 60 mostly nullable columns usually means several entities or subtypes share one table. The quickest way to see them is to look at which columns are filled together. If we group rows by which columns are non-NULL, patterns appear: rows with password_hash and last_login_at are logins, rows with vat_number and company_name are companies, and rows with iban and invoice_email are payers.
Notice the third line. Those 2,300 rows are where the confusion lives: a single row is simultaneously a person, a company and a payer, because the old model had nowhere else to put them. Every one of them will need a decision during the migration.
2Separating the Concepts With the Business
Data analysis shows the patterns, but only the people who run the business can name the concepts. A short workshop, event storming, where we put the business events on a wall such as user signed up, company subscribed, invoice sent and user invited to a team, makes the nouns visible. The concepts that usually come out are four.
| Concept | What it is | Typical columns |
|---|---|---|
| User | a person who logs in | email, password_hash, mfa, last_login_at |
| Organization | the customer company | name, vat_number, country, plan |
BillingAccount | who pays and how | invoice_email, iban or card token, currency |
| Membership | a user in an organization | user_id, organization_id, role |
The key move is Membership. A user can belong to an organization with a role, such as admin or member, and it is the relationship that the old table could not represent, which is why it duplicated people and companies into the same rows.
3The New Model
Each concept becomes a table with its own key and only the columns that describe it, most of them NOT NULL now, because a column that belongs to a concept is usually required for it.
The CHECK constraint on billing_account says a payer is either a company or an individual, never both and never neither. That rule existed before, but only in people's heads.
4Migrating With Expand and Contract
A big-bang rewrite of everything that touches accounts would take months and fail at the worst moment. Instead we use expand and contract, also called parallel change: add the new structure next to the old, move over in small reversible steps, and only remove the old structure at the end.
- Expand: create the new tablesnothing reads them yet
- Backfill from accountsbatch job, mapping table old id -> new ids
- Dual writeapplication writes old and new; reconcile daily
- Move reads feature by featurebehind flags, compare results
- Stop writing to accountskeep a compatibility view
- Contract: drop the old columns
6 steps in order. Play them, or step through them one at a time.
Each step ships on its own and can be rolled back. During the dual-write phase a reconciliation job compares old and new, and the counts it reports, for example 0 mismatches for two weeks, are the evidence to proceed to the next step.
5Edge Cases and a Shared Vocabulary
The old model allowed things that the new one must decide on explicitly. Can a user belong to two companies, for example a consultant? The new model supports it through membership, but billing and permissions code may assume one company per user. Can an organization exist without any user? What happens to the 2,300 rows that were person, company and payer at once: do they become a one-member organization, or an individual with a personal billing account? These are product decisions, and writing them down with the product owner prevents the migration from silently inventing rules.
Finally, we agree a glossary: user, organization, billing account and membership, each with a one-line definition, and use exactly those words in the API, the code, the tables and the UI. This is the ubiquitous language idea from domain-driven design. It sounds soft, but the original problem was a word, and without the glossary the new tables will drift back into an account that means three things.
6Follow-up questions
How do you keep old reports working during the change?
Replace the old table with a compatibility view called accounts, built by joining the new tables, once writes have moved. Reports that select from accounts keep working while their owners move to the new tables at their own pace. We track which reports still use the view through query logs and give a deadline before the contract step removes it.
Why not use table inheritance or one table with a type column?
A type column with nullable columns per type is what we already have, and it fails because the concepts are not subtypes of one thing: a user and an organization are related by membership, not variations of an account. Separate tables match the real relationships.
How do you handle the external API that returns account?
Version it. The old endpoint keeps returning the old shape assembled from the new tables, and a new version exposes users, organizations and memberships. Clients migrate over a published deprecation period.
7Conclusion
In this answer, we read the wide accounts table as several concepts mixed together, confirmed them with the business as User, Organization, BillingAccount and Membership, gave each its own table with real constraints, and migrated with expand and contract: new tables, backfill, dual writes with reconciliation, reads moved feature by feature, and the old columns dropped last. We also decided the edge cases explicitly and agreed one word per concept.
Open with
A table with 60 nullable columns is almost always several concepts in one, so I would start by finding them. I would profile which column groups are filled together, which usually shows logins, companies and payers, and rows that are all three at once.
Then, if they want more
Then I would run a short workshop with the product owner, event storming or similar, to name the concepts: User as the login identity, Organization as the customer company, BillingAccount as who pays, and Membership as a user in an organization with a role, which is the relationship the old table could not express.
Each becomes a table with only its own columns, mostly not null, and constraints for rules such as a billing account belonging to either a company or a person. I would not do a big-bang rewrite.
I would use expand and contract: create the new tables, backfill with a mapping from old ids, dual write with a daily reconciliation, move reads feature by feature behind flags, stop writing the old table, keep a compatibility view for old reports, and only then drop it.
Along the way, I would make the edge cases explicit decisions, such as a user in two companies, or the rows that were person and company at once. And I would agree a glossary so the API, code and tables use one word per concept, which is DDD's ubiquitous language.
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.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
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 "A product owner describes an 'account' that sometimes means a login, sometimes a billing...": https://scrivio-interview-library.netlify.app/databases/data-modeling/01bf65b90b/