Why copying tables one by one into MongoDB Atlas is the wrong move
MongoDB's own guidance says to embed the data an application reads together and to reference data that can grow without limit.
In brief
- Do not copy each table into a collection: start from how the application reads its data
- Embed when two entities have a "has-a" relationship and are always read together; reference when the embedded data could grow without limit
- Moving the data is only half the job; the other half is translating SQL into aggregation pipelines and verifying the results before cutover
MongoDB’s own job advert concedes that migrations of this kind are time-consuming and often risky.
Take a client that hands over an application that has run on SQL Server for ten years: a few hundred tables, thousands of queries scattered through Java code, and an operations team with a single question. How long will the move to MongoDB Atlas take, and what are the risks?
That is the problem MongoDB’s newly formed Field Engineering team is aimed at, with a “Forward Deployed AI Engineer” role dedicated to modernizing customers’ applications. The people in this role build outcome-driven projects themselves, from POCs and MVPs to everything in between, and bring what they learn at customer sites back into the product roadmap.
Whether or not you work at MongoDB, the skill applies anywhere a legacy system needs a new data model. The easiest place to slip, and the first thing worth practicing, is carrying table-based thinking into the world of documents.
The right question is “what does the application read together?”
In the relational model you normalize: one table per entity, joined back together with JOINs at read time. In the document model you do the opposite. Data that is always read together goes in the same document, so a single read is enough.
MongoDB’s documentation gives two signals for embedding: a “has-a” or “contains” relationship between two entities, and data that is usually queried together. The reverse is just as clear: reference when the embedded data could grow without bound.
Behind the second rule sits a hard limit: a BSON document cannot exceed 16 mebibytes. This is a wall rather than a performance tip. Hit it in production and writes fail.
A worked example: orders, line items and customers
Consider a sales system with three tables: customers, orders, order_items. The most-opened screen is “order details”, and it always needs the order along with every line item in it. The SQL behind it looks like this:
SELECT o.id, o.created_at, SUM(i.qty * i.price) AS total
FROM orders o
JOIN order_items i ON i.order_id = o.id
WHERE o.customer_id = 42
GROUP BY o.id, o.created_at;
An order “contains” its line items, and the two are always read together. Both signals are present, so the line items are embedded in the order. The number of lines in an order also has a natural ceiling: nobody puts a million items in one basket.
{
"_id": 9001,
"customerId": 42,
"createdAt": "2026-10-01T09:30:00Z",
"items": [
{ "sku": "A-17", "qty": 2, "price": 150 },
{ "sku": "B-03", "qty": 1, "price": 90 }
]
}
What about the relationship between customers and orders? Many people will want to embed the entire order history in the customer document. Run a hypothetical calculation: if each order is about 2 KB, 16 MiB (16,777,216 bytes) holds only around 8,192 orders.
A business customer ordering every day for years will hit the ceiling, and order history is exactly the kind of data that “grows without bound”. So orders live in their own collection and reference the customer through customerId.
Rewritten as an aggregation pipeline, the SQL above no longer needs a JOIN:
db.orders.aggregate([
{ $match: { customerId: 42 } },
{ $project: {
createdAt: 1,
total: { $sum: { $map: {
input: "$items", as: "i",
in: { $multiply: ["$$i.qty", "$$i.price"] }
} } }
} }
]);
When a screen also needs customer details next to the order, follow the reference with $lookup:
db.orders.aggregate([
{ $match: { _id: 9001 } },
{ $lookup: {
from: "customers",
localField: "customerId",
foreignField: "_id",
as: "customer"
} },
{ $unwind: "$customer" },
{ $project: { createdAt: 1, items: 1, "customer.name": 1 } }
]);
In practice, $lookup is perfectly fine when a preceding $match has already narrowed things down to a few documents and the screen is off the hot path, such as an admin page or a report.
If the most-opened screen also has to run $lookup constantly, that is a signal to revisit the design and consider copying a few rarely changing fields, such as the customer’s name, straight into the order document.
At the client, where do you start?
Do not start by copying data. The pattern for migrating from a relational database to Atlas on AWS, written by AWS together with a MongoDB author, opens with discovery and assessment: estimate the working set using Relational Migrator’s suggestions plus db.stats() to get the total index size, and plan the cutover early.
The pattern requires MongoDB 5.0 or later.
Only with those measurements in hand do you map the schema. Relational Migrator can read Oracle, Microsoft SQL Server, MySQL, DB2, Sybase and PostgreSQL sources, and lets you visually map the relational model to a document schema: customizing fields, splitting tables, embedding documents.
The tool speeds up the work, but the decision to embed or reference still has to come from the list of screens and queries gathered during discovery.
After the schema comes application code, the most underestimated part. Relational Migrator does translate SQL into aggregation pipelines, but you still need to run both the old and the new query on the same dataset, compare every result, and only then think about cutover.
Even AMP, the AI-assisted modernization platform MongoDB launched on September 16, 2025, comes with delivery engineers who oversee and guide the implementation: the tooling speeds up the conversion, while design decisions and verification remain the job of whoever is on site with the client.
The mistakes that sink migrations
The most common mistake is copying every table verbatim into a collection and using $lookup to replace JOINs everywhere. The result is a slower relational database dressed up as MongoDB.
The opposite mistake is just as dangerous: embedding everything, including arrays that will keep growing, such as logs, comments or transaction histories. It runs beautifully in a POC with sample data, then a year later crashes into the 16 MiB limit.
Next comes treating migration as nothing more than moving data, forgetting that thousands of SQL queries in the code must change too. And skip measuring the working set, and it is easy to size the cluster wrongly, leaving performance on cutover day worse than the old system’s, just when the client is watching most closely.
How the skill shows up on a CV
MongoDB’s job advert asks for proficiency in JavaScript plus Java or C#, along with an understanding of GenAI. That skill set mirrors the work: you have to read enterprise backend code, where the SQL lives, and write MongoDB queries in JavaScript.
On a CV, do not just write “experienced with MongoDB”. Describe a specific case: how many tables the source schema had, where you chose to embed and why, and how many queries were translated and verified.
The next time you meet a relational schema, do not ask which collection each table becomes. Ask which screen reads what together, and which arrays will keep growing.
Was this article useful?
Thanks for the feedback!
6 sources
- Senior Forward Deployed AI Engineer @ MongoDB | AlleyCorp Job Board
- MongoDB Relational Migrator | MongoDB
- Best Practices for Data Modeling in MongoDB (MongoDB Database Manual)
- MongoDB Limits and Thresholds - Database Manual - MongoDB Docs
- Migrate a relational database to MongoDB Atlas on AWS
- MongoDB Launches AI-Powered Application Modernization Platform to Reduce Technical Debt and Speed Innovation · 2025-09-16