3 ms·
I'm "eh" on ORMs, so if there are ORMers out there... one of the things I find hurts SQL and data-model comprehension is the compounded complexity of relationsh
by munk-a 8y ago
I'm "eh" on ORMs, so if there are ORMers out there... one of the things I find hurts SQL and data-model comprehension is the compounded complexity of relationships. Maybe you have authors and books - but more likely your data-model is more complex, maybe your business needs group authors by family and you also track how many copies of books are in libraries. This is still a pretty simple situation but as things get more complicated the utilization of non-materialized views can help simplify expression - but they come at the cost of pushing some of your logic into the DB where normal developers can't see it.
Have people using SQLAlchemy and other ORMs found it helpful to create fake views using the ORM system (i.e. pre-define a commonly used join) so that it can be reused as a simpler black-box unit of code where needed?
- jperras 8y agoIt's relatively straightforward to map a materialized view to an ORM entity in SQLAlchemy, if that's what you want to do: http://www.jeffwidman.com/blog/847/using-sqlalchemy-to-create-and-manage-postgresql-materialized-views/ http://www.jeffwidman.com/blog/847/using-sqlalchemy-to-creat... SQLAlchemy's ability to separate out the query API, metadata, data objects, and combine them all via mappers is very powerful. I've been using SQLA for many years, and I still regularly find some functionality that I was never aware of.
- munk-a 8y agoI more actually meant something closer to a non-materialized view, just a query segment definition that gets frequently reused - supporting it in a materialized form is all good and well but I'm more interested in how repetitive SQLA tends to come out, if a common set of tables is joined through in a wide variety of queries is there a way to reduce the number of times you can spell it out in an easy manner?