I know this question might be closed as opinion-based, but what I need right now are some opinions supported by arguments.
I am building an application with Postgres and Ecto (Elixir) as the persistence-layer. There is an entity that references itself so that you can build a tree-like structure with it. The more I am trying to do this with Ecto, the more frustrated I get.
Are ORMs simply a bad tool for creating complex DB-structures with many associations? The object-oriented way that ORM tries to enforce upon relational data seems to be a bad approach here. Objects are isolated. If they interact with other objects, they (are supposed to) send messages. Their inner details should stay hidden. Relational data form an open, transparent graph. These two worlds seem to be completely incompatible to me.
Yet, ORMs are very common and popular. Does majority of web applications work with rather isolated entities that play well with ORM, or why is that? It seems to me that if you wanted to implement any averagely complex ERD model using an ORM-framework, you have to either sacrifice concise code or performance.