4 ms·
One benefit of using an ORM is that you don't write SQL strings, you write statements and method calls. So you get better IDE support, and detect syntax errors
by captainmuon 5y ago
One benefit of using an ORM is that you don't write SQL strings, you write statements and method calls. So you get better IDE support, and detect syntax errors before they hit the database. If you are just writing a CRUD application, maybe with one or two `joins` or `order by`, then an ORM is perfect. If you are doing anything more complex, then by all means drop to plain SQL.
The real question to me is, why can't we drop the relational database? In many small projects (where you would use an ORM) it is overkill. Why can't I create a list of plain-old-data objects in my language, then add indicies on that, and do fast queries directly in the language? Most languages already have a data structure with an index on one key (a dict, hashmap or similar). With C#'s LINQ or Pythons list comprehensions we already have half of the solution.
- Zababa 5y agoFrom what I understand, data duplication can lead to consistency errors. And if you want to avoid data duplication, you're going to rewrite a relational database yourself, since you would want to put your data into normal forms to avoid duplication. I think I've read a few times on Hacker News that we already went through the alternatives to the relational database around the time of its birth, and that a few papers were published at the time on why this was a better solution than others.