Quote:
Originally Posted by RogerKwok
dave do you use ORM or just write raw SQL?
I generally write raw SQL, but of course Psycopg2 gives a few extras. I've used ORMs, but I didn't walk away with the impression they solved much. I didn't feel like they built good expressive database designs and the queries are questionable to say the least. I cry foul on object-relational impedance.
Quote:
Originally Posted by gaming_mouse
Databases are great. And I've always loved the FB quote. But it doesn't mean your application is the same thing as your database.
1. A database is not a good place for your business rules. Even with advanced integrity constraints, triggers, etc, they are not a good fit for expressing that logic, compared to something like ruby or python.
I agree with this in part, but I also disagree.
1- There is no blanket truism for each RDMS. For example, Postgres gives you insert / update / delete CTEs (mySQL has no analog to CTEs at all), which does wonders for any back and forth between the db and the system. This is, of course, one use case, but there are many other examples that can be used.
2- Data integrity is the sole purpose of a database, and ignoring this fact is not using a database correctly. Code and databases have very specific purpose, and when you say that a database isn't good for this or that, I'm not entirely sure what the point because I don't see any connection between a database and the code.
Quote:
2. A database usually serves multiple applications, or at least different but overlapping use-cases within an application. Each of these applications or use-cases is going to want its data in the format that's best for it. If your application has to work directly with ORM objects that mirror the database, you're forcing your database structure on an application that really wants a different structure.
For very simple, single-purpose applications, you won't feel any of this pain, because there won't be a mismatch between the database structure and the way your application wants to use the data.
So it's not that databases are bad, but really that, conceptually, you want each of your applications (really, each of your use-cases) to be served by it's own mini database -- a data structure custom made for it. But in large, real-world applications, you want a single physical database, mainly because that data is shared for many purposes. So to have your cake and eat it too, you have to solve this mapping problem between the database and your application code.
In databases, saying something twice doesn't make it more true. If you want to use an ORM to make specific calls or whatever, I'm not going to argue for or against. I often wonder how these things go so sideways, then I realize that much if it is that there is no understanding of the underlying data and very little understanding of the database system you are using, and that is, IMO, very dangerous.
At the end of the day, you are getting a list of tuples back from the database query. How you get said data isn't really important.