Hi all,
I have this inner monologue for the longest time and want to share it with you guys to get an answer.
I am not sure where I read it, maybe it was a coworker of mine who said (contractor who has left long time ago), "no one writes all this SQL to build DTOs’. My background is enterprise thus far and I can’t fathom where large enterprise project can be built without any kind of SQL and its DTO mapping. When it comes to ORM, I remember a video on Hibernate ORM where the presenter explained by using ORM is not always the best option.
With this said, what is the current, true strategy or stack or mental model used to build full stack application? Is the design pattern still the same, MVC or MVVM? Or like, React + Spring/Flask/ASP.NET … what about the data persistent layer?
I made a toy app not too long ago where the persistent layer is MongoDB and I used Mongoose. I did not have to write any type of SQL since I’m working with NoSQL, but is it really possible to build a full scale app without ever writing any type of data mapping by hand? Yes, Java has Lombok, but it is not widely used in my company. We use raw DTOs mapping by hand…
To give you an idea for my perspective, we use SQL Server internally and that database has close to a thousand tables and size of the database is almost 200 gigabytes. There are thousand of SQL queries that are very complex with multiple of joins and sub-queries to get result which is eventually mapped to a DTOs. Now, for me imagine that none of this SQL is required because an ORM can do it all and better, is hard to believe.
Is this really the case? Can ORM really build objects that span multiple tables? Where is my misunderstanding and confusion here?
Just to add, I am aware there are ORM for ASP.NET (entity framework), Java is Hibernate, Mongoose for Node.js, Python…
I guess, what I am getting at, can we reliably build a large scale application without every writing a single line of SQL query? Imagine there are a million of rows in a given table, won’t an ORM attempt to load the entire table into memory and filtering is done there? Isn’t it better to perform the filtering at the database layer that returns filtered result set?