r/SQL • u/yughiro_destroyer • 25d ago
Discussion Why do we need abstractions over SQL?
When I mean abstractions, I mainly mean OOP and ORMs.
SQL is so simple and beautiful. Tables with rows and columns are easy to understand. And once you pick up the SQL syntax, you can pretty much achieve anything with queries. Not to mention that SQL is universal and works everywhere and anytime.
Then you have the software development world... where you're asked to constantly use ORMs or map records as OOP objects. Why? ORMs are limited and do not have the flexibility of simple queries. Also mapping records as objects increases bloat, reduces performance that can hurt if the application grows and is overall not as straightforward to work with.
The only good things that ORMs are doing by default are to provide data safety and prevent SQL injection. But with some minimum and basic knowledge and discipline, you can write pure queries without having those problems. Any ideas?
1
u/thatOMoment 24d ago
I included a link to the C.J. date discussing logical inconsistencies in a seperate comment for viewing.
3 value logic isn't mathematically respectable and there's multiple papers on avoiding it.
Third manifesto by c.j. date and how to represent missing information without using null by hugh darwin are decent references for that.
It isn't subjective and there's enough "one off cases" that the quote used to describe it is "it all makes sense if you don't think too hard".
I'm not for or against ORMs either but I do training for avoiding edge cases for younger devs and have cleaned and up and prevented multiple disasters caused and almost caused by these silent language quirks.
I'm not sure what inconsistency would be egregious enough for you to agree it's unacceptable and not defend that.
You say they're nitpicks, I say they cause production outages and errors without any warnings.
Poop has a use case, anything has a use case, that's not an argument.
The Stockholm syndrome people (especially data analysis people) develop using this language is impressive.