đŸ”„ The DB Grill đŸ”„

Where database blog posts get flame-broiled to perfection

Cross join in MongoDB
Originally from dev.to/feed/franckpachot
February 14, 2026 ‱ Roasted by Rick "The Relic" Thompson Read Original Article

Alright, settle down, kids, let ol' Rick pour himself some lukewarm coffee from the pot that's been on since dawn and read what the geniuses have cooked up this time. "Relational database joins are, conceptually, a cartesian product..." Oh, honey. You just discovered the absolute, first-day-of-class, rock-bottom basics of set theory and you're presenting it like you've cracked the enigma code with a JavaScript framework.

Back in my day, we learned this stuff on a green screen, and if you got it wrong, you didn't just get a slow query, you brought a multi-million dollar IBM mainframe to its knees and had a guy in a suit named Mr. Henderson asking why the payroll batch job hadn't finished. You learned fast.

So you've "discovered" that you can simulate a CROSS JOIN. And to do this, you've built this... this beautiful, multi-stage Rube Goldberg machine of an aggregation pipeline. $lookup, $unwind, $sort, $project. It's got more steps than the recovery procedure for a corrupted tape reel. You know what we called this in 1985 on DB2?

SELECT f.code || '-' || s.code FROM fits f, sizes s;

There. Done. I wrote it on a napkin while waiting for my punch cards to finish compiling. You wrote a whole dissertation on it. It’s adorable, really. You spent four stages of aggregation to do what a declarative language has been doing for fifty years. But you get to use a dollar sign in front of everything, so I guess it feels like you're innovating.

And then we get to the real meat of the genius here. The "better model": embedding. You’ve just performed this heroic query to generate all the combinations, only to turn around and stuff them all back into one of the tables. You’ve rediscovered denormalization! Congratulations! We used to do that, too. We called it "a necessary evil when the I/O on the disk controller is about to melt" and we spent the next six months writing complex COBOL batch jobs to keep the duplicated data from turning into a toxic waste dump of inconsistency.

But you, you’ve branded it as a feature. "Duplication has the advantage of returning all required information in a single read." Yes, it does. It also has the advantage of turning a simple update into a nightmare safari through nested arrays.

You’re creating data integrity problems and then patting yourself on the back for inventing clever, document-specific ways to clean up your own mess. We had a solution for this. It was called normalization. It was boring. It was rigid. And it worked.

But this part... this is the chef's kiss right here:

Unlike relational databases—where data can be modified through ad‑hoc SQL and business rules must therefore be enforced at the database level—MongoDB applications are typically domain‑driven, with clear ownership of data and a single responsibility for performing updates.

Bless your heart. You're saying that because you’ve made it impossible for anyone to run a simple UPDATE statement, your data is now safer? You haven't created a fortress of data integrity; you’ve created a walled garden of blissful ignorance. You've abdicated the single most important responsibility of a database—to guarantee the integrity of the data it holds—and passed the buck to the "application's service."

I’ve seen what happens when the "application's service" is responsible for consistency. I’ve seen it in production, at 3 a.m., with a terabyte of corrupted data. I've spent a weekend sleeping on a cot in a data center, babysitting a tape-to-tape restore because some hotshot programmer thought he was too good for a foreign key constraint. Your "domain-driven" approach is just a fancy way of saying, "we trust that Todd, the new front-end intern, will never, ever write a bug." Good luck with that.

And then you have the audacity to wrap it all up by explaining what a one-to-many relationship and a foreign key is, as if you're bequeathing ancient, forgotten knowledge to the masses. These aren't "concepts" that MongoDB "exposes as modeling choices." They are fundamental principles of data management that you are choosing to ignore. It’s like saying a car "exposes the concept of wheels as a mobility choice." No, son, you need the wheels.

So go on, build your systems where every service owns its little blob of duplicated JSON. It’s a bold strategy. Let's see how it works out when your business rules "evolve" a little more than you planned for.

Now if you'll excuse me, I've got a JCL script that's been running flawlessly since 1988. It probably needs a stern talking-to for being so reliable. Keep up the good work, kid. You're making my pension plan look smarter every day.